Home | History | Annotate | Download | only in LoopVectorize
      1 ; RUN: opt -basicaa -loop-vectorize -enable-mem-access-versioning -force-vector-width=2 -force-vector-unroll=1 < %s -S | FileCheck %s
      2 
      3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
      4 
      5 ; CHECK-LABEL: test
      6 define void @test(i32* noalias %A, i64 %AStride,
      7                   i32* noalias %B, i32 %BStride,
      8                   i32* noalias %C, i64 %CStride, i32 %N) {
      9 entry:
     10   %cmp13 = icmp eq i32 %N, 0
     11   br i1 %cmp13, label %for.end, label %for.body.preheader
     12 
     13 ; CHECK-DAG: icmp ne i64 %AStride, 1
     14 ; CHECK-DAG: icmp ne i32 %BStride, 1
     15 ; CHECK-DAG: icmp ne i64 %CStride, 1
     16 ; CHECK: or
     17 ; CHECK: or
     18 ; CHECK: br
     19 
     20 ; CHECK: vector.body
     21 ; CHECK: load <2 x i32>
     22 
     23 for.body.preheader:
     24   br label %for.body
     25 
     26 for.body:
     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
     44 
     45 for.end.loopexit:
     46   br label %for.end
     47 
     48 for.end:
     49   ret void
     50 }
     51 
     52 ; We used to crash on this function because we removed the fptosi cast when
     53 ; replacing the symbolic stride '%conv'.
     54 ; PR18480
     55 
     56 ; CHECK-LABEL: fn1
     57 ; CHECK: load <2 x double>
     58 
     59 define void @fn1(double* noalias %x, double* noalias %c, double %a) {
     60 entry:
     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
     64 
     65 for.body.preheader:
     66   br label %for.body
     67 
     68 for.body:
     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
     81 
     82 for.end.loopexit:
     83   br label %for.end
     84 
     85 for.end:
     86   ret void
     87 }
     88