1 ; RUN: llc -mtriple=i686-windows -mattr=+sse2 < %s | FileCheck %s
3 target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
4 target triple = "i686-pc-windows-msvc"
6 ; There is a conflict between lowering the X86 memory intrinsics and the "base"
7 ; register used to address stack locals. See X86RegisterInfo::hasBaseRegister
8 ; for when this is necessary. Typically, we chose ESI for the base register,
9 ; which all of the X86 string instructions use.
11 ; The pattern of vector icmp and extractelement is used in these tests because
12 ; it forces creation of an aligned stack temporary. Perhaps such temporaries
13 ; shouldn't be aligned.
15 declare void @escape_vla_and_icmp(i8*, i1 zeroext)
16 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1)
17 declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1)
19 define i32 @memcpy_novla_vector(<4 x i32>* %vp0, i8* %a, i8* %b, i32 %n, i1 zeroext %cond) {
20 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %a, i8* %b, i32 128, i32 4, i1 false)
21 br i1 %cond, label %spill_vectors, label %no_vectors
27 %vp1 = getelementptr <4 x i32>* %vp0, i32 1
28 %v0 = load <4 x i32>* %vp0
29 %v1 = load <4 x i32>* %vp1
30 %vicmp = icmp slt <4 x i32> %v0, %v1
31 %icmp = extractelement <4 x i1> %vicmp, i32 0
32 call void @escape_vla_and_icmp(i8* null, i1 zeroext %icmp)
33 %r = extractelement <4 x i32> %v0, i32 0
37 ; CHECK-LABEL: _memcpy_novla_vector:
38 ; CHECK: andl $-16, %esp
39 ; CHECK-DAG: movl $32, %ecx
40 ; CHECK-DAG: movl {{.*}}, %esi
41 ; CHECK-DAG: movl {{.*}}, %edi
44 define i32 @memcpy_vla_vector(<4 x i32>* %vp0, i8* %a, i8* %b, i32 %n, i1 zeroext %cond) {
45 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %a, i8* %b, i32 128, i32 4, i1 false)
46 br i1 %cond, label %spill_vectors, label %no_vectors
52 %vp1 = getelementptr <4 x i32>* %vp0, i32 1
53 %v0 = load <4 x i32>* %vp0
54 %v1 = load <4 x i32>* %vp1
55 %vicmp = icmp slt <4 x i32> %v0, %v1
56 %icmp = extractelement <4 x i1> %vicmp, i32 0
57 %vla = alloca i8, i32 %n
58 call void @escape_vla_and_icmp(i8* %vla, i1 zeroext %icmp)
59 %r = extractelement <4 x i32> %v0, i32 0
63 ; CHECK-LABEL: _memcpy_vla_vector:
64 ; CHECK: andl $-16, %esp
65 ; CHECK: movl %esp, %esi
66 ; CHECK: movl $128, {{.*}}(%esp)
67 ; CHECK: calll _memcpy
68 ; CHECK: calll __chkstk
70 ; stosd doesn't clobber esi, so we can use it.
72 define i32 @memset_vla_vector(<4 x i32>* %vp0, i8* %a, i32 %n, i1 zeroext %cond) {
73 call void @llvm.memset.p0i8.i32(i8* %a, i8 42, i32 128, i32 4, i1 false)
74 br i1 %cond, label %spill_vectors, label %no_vectors
80 %vp1 = getelementptr <4 x i32>* %vp0, i32 1
81 %v0 = load <4 x i32>* %vp0
82 %v1 = load <4 x i32>* %vp1
83 %vicmp = icmp slt <4 x i32> %v0, %v1
84 %icmp = extractelement <4 x i1> %vicmp, i32 0
85 %vla = alloca i8, i32 %n
86 call void @escape_vla_and_icmp(i8* %vla, i1 zeroext %icmp)
87 %r = extractelement <4 x i32> %v0, i32 0
91 ; CHECK-LABEL: _memset_vla_vector:
92 ; CHECK: andl $-16, %esp
93 ; CHECK: movl %esp, %esi
94 ; CHECK-DAG: movl $707406378, %eax # imm = 0x2A2A2A2A
95 ; CHECK-DAG: movl $32, %ecx
96 ; CHECK-DAG: movl {{.*}}, %edi
97 ; CHECK-NOT: movl {{.*}}, %esi
100 ; Add a test for memcmp if we ever add a special lowering for it.