diff options
| author | Nadav Rotem <nrotem@apple.com> | 2013-01-05 01:15:47 +0000 |
|---|---|---|
| committer | Nadav Rotem <nrotem@apple.com> | 2013-01-05 01:15:47 +0000 |
| commit | e9f5bfd5e905338fd93d6c89b8579e68deff567f (patch) | |
| tree | 92d2e6d77206c4792b2484e0cdbd7165fb9042a3 /llvm/test/Transforms | |
| parent | 6d9dafe3ffec06cce37c1bd930e24f2de042887c (diff) | |
| download | bcm5719-llvm-e9f5bfd5e905338fd93d6c89b8579e68deff567f.tar.gz bcm5719-llvm-e9f5bfd5e905338fd93d6c89b8579e68deff567f.zip | |
iLoopVectorize: Non commutative operators can be used as reduction variables as long as the reduction chain is used in the LHS.
PR14803.
llvm-svn: 171583
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/LoopVectorize/gcc-examples.ll | 2 | ||||
| -rw-r--r-- | llvm/test/Transforms/LoopVectorize/reduction.ll | 32 |
2 files changed, 31 insertions, 3 deletions
diff --git a/llvm/test/Transforms/LoopVectorize/gcc-examples.ll b/llvm/test/Transforms/LoopVectorize/gcc-examples.ll index de3f59f41af..b8b125f3ee7 100644 --- a/llvm/test/Transforms/LoopVectorize/gcc-examples.ll +++ b/llvm/test/Transforms/LoopVectorize/gcc-examples.ll @@ -241,7 +241,7 @@ define void @example8(i32 %x) nounwind uwtable ssp { } ;CHECK: @example9 -;CHECK-NOT: phi <4 x i32> +;CHECK: phi <4 x i32> ;CHECK: ret i32 define i32 @example9() nounwind uwtable readonly ssp { br label %1 diff --git a/llvm/test/Transforms/LoopVectorize/reduction.ll b/llvm/test/Transforms/LoopVectorize/reduction.ll index fbce072b8b1..6b29e2537bd 100644 --- a/llvm/test/Transforms/LoopVectorize/reduction.ll +++ b/llvm/test/Transforms/LoopVectorize/reduction.ll @@ -296,11 +296,12 @@ for.end: ; preds = %for.body, %entry ret i32 %x.0.lcssa } -;CHECK: @reduction_sub_lhs +; In this code the subtracted variable is on the RHS and this is not an induction variable. +;CHECK: @reduction_sub_rhs ;CHECK-NOT: phi <4 x i32> ;CHECK-NOT: sub nsw <4 x i32> ;CHECK: ret i32 -define i32 @reduction_sub_lhs(i32 %n, i32* noalias nocapture %A) nounwind uwtable readonly { +define i32 @reduction_sub_rhs(i32 %n, i32* noalias nocapture %A) nounwind uwtable readonly { entry: %cmp4 = icmp sgt i32 %n, 0 br i1 %cmp4, label %for.body, label %for.end @@ -320,3 +321,30 @@ for.end: ; preds = %for.body, %entry %x.0.lcssa = phi i32 [ 0, %entry ], [ %sub, %for.body ] ret i32 %x.0.lcssa } + + +; In this test the reduction variable is on the LHS and we can vectorize it. +;CHECK: @reduction_sub_lhs +;CHECK: phi <4 x i32> +;CHECK: sub nsw <4 x i32> +;CHECK: ret i32 +define i32 @reduction_sub_lhs(i32 %n, i32* noalias nocapture %A) nounwind uwtable readonly { +entry: + %cmp4 = icmp sgt i32 %n, 0 + br i1 %cmp4, label %for.body, label %for.end + +for.body: ; preds = %entry, %for.body + %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] + %x.05 = phi i32 [ %sub, %for.body ], [ 0, %entry ] + %arrayidx = getelementptr inbounds i32* %A, i64 %indvars.iv + %0 = load i32* %arrayidx, align 4 + %sub = sub nsw i32 %x.05, %0 + %indvars.iv.next = add i64 %indvars.iv, 1 + %lftr.wideiv = trunc i64 %indvars.iv.next to i32 + %exitcond = icmp eq i32 %lftr.wideiv, %n + br i1 %exitcond, label %for.end, label %for.body + +for.end: ; preds = %for.body, %entry + %x.0.lcssa = phi i32 [ 0, %entry ], [ %sub, %for.body ] + ret i32 %x.0.lcssa +} |

