aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2011-06-30 19:02:17 +0000
committerAndrew Trick <atrick@apple.com>2011-06-30 19:02:17 +0000
commit6e0ce24e0ca8b0dc05872b9b4cec3a18972bee40 (patch)
treeb947070dc15f3de66e7bcee1f32c9cde490f55dd /test/Transforms/IndVarSimplify/no-iv-rewrite.ll
parent16f9924000a8d513353cd5c69d1d6307016fe280 (diff)
downloadexternal_llvm-6e0ce24e0ca8b0dc05872b9b4cec3a18972bee40.zip
external_llvm-6e0ce24e0ca8b0dc05872b9b4cec3a18972bee40.tar.gz
external_llvm-6e0ce24e0ca8b0dc05872b9b4cec3a18972bee40.tar.bz2
indvars -disable-iv-rewrite: handle cloning binary operators that cannot overflow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134177 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/IndVarSimplify/no-iv-rewrite.ll')
-rw-r--r--test/Transforms/IndVarSimplify/no-iv-rewrite.ll42
1 files changed, 38 insertions, 4 deletions
diff --git a/test/Transforms/IndVarSimplify/no-iv-rewrite.ll b/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
index 0187170..f38b54e 100644
--- a/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
+++ b/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
@@ -160,6 +160,8 @@ define void @maxvisitor(i32 %limit, i32* %base) nounwind {
entry:
br label %loop
+; Test inserting a truncate at a phi use.
+;
; CHECK: loop:
; CHECK: phi i64
; CHECK: trunc
@@ -189,14 +191,17 @@ exit:
ret void
}
-; CHECK: loop:
-; CHECK: phi i32
-; CHECK-NOT: phi
-; CHECK: exit:
define void @identityphi(i32 %limit) nounwind {
entry:
br label %loop
+; Test an edge case of removing an identity phi that directly feeds
+; back to the loop iv.
+;
+; CHECK: loop:
+; CHECK: phi i32
+; CHECK-NOT: phi
+; CHECK: exit:
loop:
%iv = phi i32 [ 0, %entry], [ %iv.next, %control ]
br i1 undef, label %if.then, label %control
@@ -212,3 +217,32 @@ control:
exit:
ret void
}
+
+define i64 @cloneOr(i32 %limit, i64* %base) nounwind {
+entry:
+ ; ensure that the loop can't overflow
+ %halfLim = ashr i32 %limit, 2
+ br label %loop
+
+; Test cloning an or, which is not an OverflowBinaryOperator.
+;
+; CHECK: loop:
+; CHECK: phi i64
+; CHECK-NOT: sext
+; CHECK: or i64
+; CHECK: exit:
+loop:
+ %iv = phi i32 [ 0, %entry], [ %iv.next, %loop ]
+ %t1 = sext i32 %iv to i64
+ %adr = getelementptr i64* %base, i64 %t1
+ %val = load i64* %adr
+ %t2 = or i32 %iv, 1
+ %t3 = sext i32 %t2 to i64
+ %iv.next = add i32 %iv, 2
+ %cmp = icmp slt i32 %iv.next, %halfLim
+ br i1 %cmp, label %loop, label %exit
+
+exit:
+ %result = and i64 %val, %t3
+ ret i64 %result
+}