1 ; RUN: opt -basicaa -loop-vectorize -enable-mem-access-versioning -force-vector-width=2 -force-vector-unroll=1 < %s -S | FileCheck %s
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
6 define void @test(i32* noalias %A, i64 %AStride,
7 i32* noalias %B, i32 %BStride,
8 i32* noalias %C, i64 %CStride, i32 %N) {
10 %cmp13 = icmp eq i32 %N, 0
11 br i1 %cmp13, label %for.end, label %for.body.preheader
13 ; CHECK-DAG: icmp ne i64 %AStride, 1
14 ; CHECK-DAG: icmp ne i32 %BStride, 1
15 ; CHECK-DAG: icmp ne i64 %CStride, 1
21 ; CHECK: load <2 x i32>
27 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
28 %iv.trunc = trunc i64 %indvars.iv to i32
29 %mul = mul i32 %iv.trunc, %BStride
30 %mul64 = zext i32 %mul to i64
31 %arrayidx = getelementptr inbounds i32* %B, i64 %mul64
32 %0 = load i32* %arrayidx, align 4
33 %mul2 = mul nsw i64 %indvars.iv, %CStride
34 %arrayidx3 = getelementptr inbounds i32* %C, i64 %mul2
35 %1 = load i32* %arrayidx3, align 4
36 %mul4 = mul nsw i32 %1, %0
37 %mul3 = mul nsw i64 %indvars.iv, %AStride
38 %arrayidx7 = getelementptr inbounds i32* %A, i64 %mul3
39 store i32 %mul4, i32* %arrayidx7, align 4
40 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
41 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
42 %exitcond = icmp eq i32 %lftr.wideiv, %N
43 br i1 %exitcond, label %for.end.loopexit, label %for.body
52 ; We used to crash on this function because we removed the fptosi cast when
53 ; replacing the symbolic stride '%conv'.
57 ; CHECK: load <2 x double>
59 define void @fn1(double* noalias %x, double* noalias %c, double %a) {
61 %conv = fptosi double %a to i32
62 %cmp8 = icmp sgt i32 %conv, 0
63 br i1 %cmp8, label %for.body.preheader, label %for.end
69 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
70 %0 = trunc i64 %indvars.iv to i32
71 %mul = mul nsw i32 %0, %conv
72 %idxprom = sext i32 %mul to i64
73 %arrayidx = getelementptr inbounds double* %x, i64 %idxprom
74 %1 = load double* %arrayidx, align 8
75 %arrayidx3 = getelementptr inbounds double* %c, i64 %indvars.iv
76 store double %1, double* %arrayidx3, align 8
77 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
78 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
79 %exitcond = icmp eq i32 %lftr.wideiv, %conv
80 br i1 %exitcond, label %for.end.loopexit, label %for.body