Home | History | Annotate | Download | only in LoopVectorize
      1 ; RUN: opt < %s  -loop-vectorize -force-vector-unroll=1 -force-vector-width=4 -enable-if-conversion -dce -instcombine -S | FileCheck %s
      2 
      3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
      4 target triple = "x86_64-apple-macosx10.9.0"
      5 
      6 ;CHECK-LABEL: @reduction_func(
      7 ;CHECK-NOT: load <4 x i32>
      8 ;CHECK: ret i32
      9 define i32 @reduction_func(i32* nocapture %A, i32 %n) nounwind uwtable readonly ssp {
     10 entry:
     11   %cmp10 = icmp sgt i32 %n, 0
     12   br i1 %cmp10, label %for.body, label %for.end
     13 
     14 for.body:                                         ; preds = %entry, %for.inc
     15   %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
     16   %sum.011 = phi i32 [ %sum.1, %for.inc ], [ 0, %entry ]
     17   %arrayidx = getelementptr inbounds i32* %A, i64 %indvars.iv
     18   %0 = load i32* %arrayidx, align 4
     19   %cmp1 = icmp sgt i32 %0, 30
     20   br i1 %cmp1, label %if.then, label %for.inc
     21 
     22 if.then:                                          ; preds = %for.body
     23   %add = add i32 %sum.011, 2
     24   %add4 = add i32 %add, %0
     25   br label %for.inc
     26 
     27 for.inc:                                          ; preds = %for.body, %if.then
     28   %sum.1 = phi i32 [ %add4, %if.then ], [ %sum.011, %for.body ]
     29   %indvars.iv.next = add i64 %indvars.iv, 1
     30   %lftr.wideiv = trunc i64 %indvars.iv.next to i32
     31   %exitcond = icmp eq i32 %lftr.wideiv, %n
     32   br i1 %exitcond, label %for.end, label %for.body
     33 
     34 for.end:                                          ; preds = %for.inc, %entry
     35   %sum.0.lcssa = phi i32 [ 0, %entry ], [ 4, %for.inc ]
     36   ret i32 %sum.0.lcssa
     37 }
     38 
     39