1*f31811f2SFangrui Song; RUN: opt -basic-aa -loop-vectorize -enable-mem-access-versioning -force-vector-width=2 -force-vector-interleave=1 < %s -S | FileCheck %s 2cee313d2SEric Christopher 3cee313d2SEric Christophertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4cee313d2SEric Christopher 5cee313d2SEric Christopher; Check that we version this loop with speculating the value 1 for symbolic 6cee313d2SEric Christopher; strides. This also checks that the symbolic stride information is correctly 7cee313d2SEric Christopher; propagated to the memcheck generation. Without this the loop wouldn't 8cee313d2SEric Christopher; vectorize because we couldn't determine the array bounds for the required 9cee313d2SEric Christopher; memchecks. 10cee313d2SEric Christopher 11cee313d2SEric Christopher; CHECK-LABEL: test 12cee313d2SEric Christopherdefine void @test(i32* %A, i64 %AStride, 13cee313d2SEric Christopher i32* %B, i32 %BStride, 14cee313d2SEric Christopher i32* %C, i64 %CStride, i32 %N) { 15cee313d2SEric Christopherentry: 16cee313d2SEric Christopher %cmp13 = icmp eq i32 %N, 0 17cee313d2SEric Christopher br i1 %cmp13, label %for.end, label %for.body.preheader 18cee313d2SEric Christopher 19cee313d2SEric Christopher; CHECK-DAG: icmp ne i64 %AStride, 1 20cee313d2SEric Christopher; CHECK-DAG: icmp ne i32 %BStride, 1 21cee313d2SEric Christopher; CHECK-DAG: icmp ne i64 %CStride, 1 22cee313d2SEric Christopher; CHECK: or 23cee313d2SEric Christopher; CHECK: or 24cee313d2SEric Christopher; CHECK: br 25cee313d2SEric Christopher 26cee313d2SEric Christopher; CHECK: vector.body 27cee313d2SEric Christopher; CHECK: load <2 x i32> 28cee313d2SEric Christopher 29cee313d2SEric Christopherfor.body.preheader: 30cee313d2SEric Christopher br label %for.body 31cee313d2SEric Christopher 32cee313d2SEric Christopherfor.body: 33cee313d2SEric Christopher %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ] 34cee313d2SEric Christopher %iv.trunc = trunc i64 %indvars.iv to i32 35cee313d2SEric Christopher %mul = mul i32 %iv.trunc, %BStride 36cee313d2SEric Christopher %mul64 = zext i32 %mul to i64 37cee313d2SEric Christopher %arrayidx = getelementptr inbounds i32, i32* %B, i64 %mul64 38cee313d2SEric Christopher %0 = load i32, i32* %arrayidx, align 4 39cee313d2SEric Christopher %mul2 = mul nsw i64 %indvars.iv, %CStride 40cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds i32, i32* %C, i64 %mul2 41cee313d2SEric Christopher %1 = load i32, i32* %arrayidx3, align 4 42cee313d2SEric Christopher %mul4 = mul nsw i32 %1, %0 43cee313d2SEric Christopher %mul3 = mul nsw i64 %indvars.iv, %AStride 44cee313d2SEric Christopher %arrayidx7 = getelementptr inbounds i32, i32* %A, i64 %mul3 45cee313d2SEric Christopher store i32 %mul4, i32* %arrayidx7, align 4 46cee313d2SEric Christopher %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 47cee313d2SEric Christopher %lftr.wideiv = trunc i64 %indvars.iv.next to i32 48cee313d2SEric Christopher %exitcond = icmp eq i32 %lftr.wideiv, %N 49cee313d2SEric Christopher br i1 %exitcond, label %for.end.loopexit, label %for.body 50cee313d2SEric Christopher 51cee313d2SEric Christopherfor.end.loopexit: 52cee313d2SEric Christopher br label %for.end 53cee313d2SEric Christopher 54cee313d2SEric Christopherfor.end: 55cee313d2SEric Christopher ret void 56cee313d2SEric Christopher} 57cee313d2SEric Christopher 58cee313d2SEric Christopher; We used to crash on this function because we removed the fptosi cast when 59cee313d2SEric Christopher; replacing the symbolic stride '%conv'. 60cee313d2SEric Christopher; PR18480 61cee313d2SEric Christopher 62cee313d2SEric Christopher; CHECK-LABEL: fn1 63cee313d2SEric Christopher; CHECK: load <2 x double> 64cee313d2SEric Christopher 65cee313d2SEric Christopherdefine void @fn1(double* noalias %x, double* noalias %c, double %a) { 66cee313d2SEric Christopherentry: 67cee313d2SEric Christopher %conv = fptosi double %a to i32 68cee313d2SEric Christopher %conv2 = add i32 %conv, 4 69cee313d2SEric Christopher %cmp8 = icmp sgt i32 %conv2, 0 70cee313d2SEric Christopher br i1 %cmp8, label %for.body.preheader, label %for.end 71cee313d2SEric Christopher 72cee313d2SEric Christopherfor.body.preheader: 73cee313d2SEric Christopher br label %for.body 74cee313d2SEric Christopher 75cee313d2SEric Christopherfor.body: 76cee313d2SEric Christopher %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ] 77cee313d2SEric Christopher %0 = trunc i64 %indvars.iv to i32 78cee313d2SEric Christopher %mul = mul nsw i32 %0, %conv 79cee313d2SEric Christopher %idxprom = sext i32 %mul to i64 80cee313d2SEric Christopher %arrayidx = getelementptr inbounds double, double* %x, i64 %idxprom 81cee313d2SEric Christopher %1 = load double, double* %arrayidx, align 8 82cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds double, double* %c, i64 %indvars.iv 83cee313d2SEric Christopher store double %1, double* %arrayidx3, align 8 84cee313d2SEric Christopher %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 85cee313d2SEric Christopher %lftr.wideiv = trunc i64 %indvars.iv.next to i32 86cee313d2SEric Christopher %exitcond = icmp eq i32 %lftr.wideiv, %conv2 87cee313d2SEric Christopher br i1 %exitcond, label %for.end.loopexit, label %for.body 88cee313d2SEric Christopher 89cee313d2SEric Christopherfor.end.loopexit: 90cee313d2SEric Christopher br label %for.end 91cee313d2SEric Christopher 92cee313d2SEric Christopherfor.end: 93cee313d2SEric Christopher ret void 94cee313d2SEric Christopher} 95