diff options
| author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-10-16 01:00:47 +0000 |
|---|---|---|
| committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-10-16 01:00:47 +0000 |
| commit | 37e87c2023821ded5c35096d794bbb55c9cc5899 (patch) | |
| tree | dea4ff599d2a428ec335eb4948a800cbe3d5ca8b /llvm/test/Transforms | |
| parent | 472840a3d38cb4f2f2c4d59618e9fd7a6adcc9eb (diff) | |
| download | bcm5719-llvm-37e87c2023821ded5c35096d794bbb55c9cc5899.tar.gz bcm5719-llvm-37e87c2023821ded5c35096d794bbb55c9cc5899.zip | |
[IndVars] Have `cloneArithmeticIVUser` guess better
Summary:
`cloneArithmeticIVUser` currently trips over expression like `add %iv,
-1` when `%iv` is being zero extended -- it tries to construct the
widened use as `add %iv.zext, zext(-1)` and (correctly) fails to prove
equivalence to `zext(add %iv, -1)` (here the SCEV for `%iv` is
`{1,+,1}`).
This change teaches `IndVars` to try sign extending the non-IV operand
if that makes the newly constructed IV use equivalent to the widened
narrow IV use.
Reviewers: atrick, hfinkel, reames
Subscribers: sanjoy, llvm-commits
Differential Revision: http://reviews.llvm.org/D13717
llvm-svn: 250483
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/IndVarSimplify/iv-widen.ll | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/iv-widen.ll b/llvm/test/Transforms/IndVarSimplify/iv-widen.ll index 464b03ce559..ccf9fa0aa0a 100644 --- a/llvm/test/Transforms/IndVarSimplify/iv-widen.ll +++ b/llvm/test/Transforms/IndVarSimplify/iv-widen.ll @@ -6,7 +6,7 @@ target datalayout = "n8:16:32:64" target triple = "x86_64-apple-darwin" -; CHECK-LABEL: @sloop +; CHECK-LABEL: @loop_0 ; CHECK-LABEL: B18: ; Only one phi now. ; CHECK: phi @@ -16,7 +16,7 @@ target triple = "x86_64-apple-darwin" ; One trunc for the dummy() call. ; CHECK-LABEL: exit24: ; CHECK: trunc i64 {{.*}}lcssa.wide to i32 -define void @sloop(i32* %a) { +define void @loop_0(i32* %a) { Prologue: br i1 undef, label %B18, label %B6 @@ -41,4 +41,30 @@ exit24: ; preds = %B18 unreachable } +define void @loop_1(i32 %lim) { +; CHECK-LABEL: @loop_1( + entry: + %entry.cond = icmp ne i32 %lim, 0 + br i1 %entry.cond, label %loop, label %leave + + loop: +; CHECK: loop: +; CHECK: %indvars.iv = phi i64 [ 1, %loop.preheader ], [ %indvars.iv.next, %loop ] +; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 +; CHECK: [[IV_INC:%[^ ]+]] = add nsw i64 %indvars.iv, -1 +; CHECK: call void @dummy.i64(i64 [[IV_INC]]) + + %iv = phi i32 [ 1, %entry ], [ %iv.inc, %loop ] + %iv.inc = add i32 %iv, 1 + %iv.inc.sub = add i32 %iv, -1 + %iv.inc.sub.zext = zext i32 %iv.inc.sub to i64 + call void @dummy.i64(i64 %iv.inc.sub.zext) + %be.cond = icmp ult i32 %iv.inc, %lim + br i1 %be.cond, label %loop, label %leave + + leave: + ret void +} + declare void @dummy(i32) +declare void @dummy.i64(i64) |

