1; RUN: llc -mtriple=i686-windows -mattr=+sse2 < %s | FileCheck %s 2 3target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32" 4target triple = "i686-pc-windows-msvc" 5 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. 10 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. 14 15declare void @escape_vla_and_icmp(i8*, i1 zeroext) 16declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1) 17declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) 18 19define 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 22 23no_vectors: 24 ret i32 0 25 26spill_vectors: 27 %vp1 = getelementptr <4 x i32>, <4 x i32>* %vp0, i32 1 28 %v0 = load <4 x i32>, <4 x i32>* %vp0 29 %v1 = load <4 x i32>, <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 34 ret i32 %r 35} 36 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 42; CHECK: rep;movsl 43 44define 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 47 48no_vectors: 49 ret i32 0 50 51spill_vectors: 52 %vp1 = getelementptr <4 x i32>, <4 x i32>* %vp0, i32 1 53 %v0 = load <4 x i32>, <4 x i32>* %vp0 54 %v1 = load <4 x i32>, <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 60 ret i32 %r 61} 62 63; CHECK-LABEL: _memcpy_vla_vector: 64; CHECK: andl $-16, %esp 65; CHECK: movl %esp, %esi 66; CHECK: pushl $128 67; CHECK: calll _memcpy 68; CHECK: calll __chkstk 69 70; stosd doesn't clobber esi, so we can use it. 71 72define 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 75 76no_vectors: 77 ret i32 0 78 79spill_vectors: 80 %vp1 = getelementptr <4 x i32>, <4 x i32>* %vp0, i32 1 81 %v0 = load <4 x i32>, <4 x i32>* %vp0 82 %v1 = load <4 x i32>, <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 88 ret i32 %r 89} 90 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 98; CHECK: rep;stosl 99 100; Add a test for memcmp if we ever add a special lowering for it. 101