summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/phi.ll
diff options
context:
space:
mode:
authorFrits van Bommel <fvbommel@gmail.com>2011-04-16 14:31:50 +0000
committerFrits van Bommel <fvbommel@gmail.com>2011-04-16 14:31:50 +0000
commit338af5e749b147b260affa1a893f3f65a1e13337 (patch)
treebd742b4c21ed1cbd690e2000a0192075ecf9c9fe /test/Transforms/InstCombine/phi.ll
parentcbc5f407eff618225a2fd4363f67d660607e6c2d (diff)
downloadllvm-338af5e749b147b260affa1a893f3f65a1e13337.tar.gz
llvm-338af5e749b147b260affa1a893f3f65a1e13337.tar.bz2
llvm-338af5e749b147b260affa1a893f3f65a1e13337.tar.xz
Add test cases for Jay's r129641 and fix a 32-bit-centric testcase in a file with a 64-bit datalayout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/phi.ll')
-rw-r--r--test/Transforms/InstCombine/phi.ll86
1 files changed, 81 insertions, 5 deletions
diff --git a/test/Transforms/InstCombine/phi.ll b/test/Transforms/InstCombine/phi.ll
index 62c6a63a7e..cd865ae81b 100644
--- a/test/Transforms/InstCombine/phi.ll
+++ b/test/Transforms/InstCombine/phi.ll
@@ -197,25 +197,25 @@ declare i1 @test11a()
define i1 @test11() {
entry:
%a = alloca i32
- %i = ptrtoint i32* %a to i32
+ %i = ptrtoint i32* %a to i64
%b = call i1 @test11a()
br i1 %b, label %one, label %two
one:
- %x = phi i32 [%i, %entry], [%y, %two]
+ %x = phi i64 [%i, %entry], [%y, %two]
%c = call i1 @test11a()
br i1 %c, label %two, label %end
two:
- %y = phi i32 [%i, %entry], [%x, %one]
+ %y = phi i64 [%i, %entry], [%x, %one]
%d = call i1 @test11a()
br i1 %d, label %one, label %end
end:
- %f = phi i32 [ %x, %one], [%y, %two]
+ %f = phi i64 [ %x, %one], [%y, %two]
; Change the %f to %i, and the optimizer suddenly becomes a lot smarter
; even though %f must equal %i at this point
- %g = inttoptr i32 %f to i32*
+ %g = inttoptr i64 %f to i32*
store i32 10, i32* %g
%z = call i1 @test11a()
ret i1 %z
@@ -544,3 +544,79 @@ BB2:
; CHECK-NEXT: %C = add nuw i32 %A, 1
; CHECK-NEXT: ret i32 %C
}
+
+; Same as test11, but used to be missed due to a bug.
+declare i1 @test25a()
+
+define i1 @test25() {
+entry:
+ %a = alloca i32
+ %i = ptrtoint i32* %a to i64
+ %b = call i1 @test25a()
+ br i1 %b, label %one, label %two
+
+one:
+ %x = phi i64 [%y, %two], [%i, %entry]
+ %c = call i1 @test25a()
+ br i1 %c, label %two, label %end
+
+two:
+ %y = phi i64 [%x, %one], [%i, %entry]
+ %d = call i1 @test25a()
+ br i1 %d, label %one, label %end
+
+end:
+ %f = phi i64 [ %x, %one], [%y, %two]
+ ; Change the %f to %i, and the optimizer suddenly becomes a lot smarter
+ ; even though %f must equal %i at this point
+ %g = inttoptr i64 %f to i32*
+ store i32 10, i32* %g
+ %z = call i1 @test25a()
+ ret i1 %z
+; CHECK: @test25
+; CHECK-NOT: phi i32
+; CHECK: ret i1 %z
+}
+
+declare i1 @test26a()
+
+define i1 @test26(i32 %n) {
+entry:
+ %a = alloca i32
+ %i = ptrtoint i32* %a to i64
+ %b = call i1 @test26a()
+ br label %one
+
+one:
+ %x = phi i64 [%y, %two], [%w, %three], [%i, %entry]
+ %c = call i1 @test26a()
+ switch i32 %n, label %end [
+ i32 2, label %two
+ i32 3, label %three
+ ]
+
+two:
+ %y = phi i64 [%x, %one], [%w, %three]
+ %d = call i1 @test26a()
+ switch i32 %n, label %end [
+ i32 10, label %one
+ i32 30, label %three
+ ]
+
+three:
+ %w = phi i64 [%y, %two], [%x, %one]
+ %e = call i1 @test26a()
+ br i1 %e, label %one, label %two
+
+end:
+ %f = phi i64 [ %x, %one], [%y, %two]
+ ; Change the %f to %i, and the optimizer suddenly becomes a lot smarter
+ ; even though %f must equal %i at this point
+ %g = inttoptr i64 %f to i32*
+ store i32 10, i32* %g
+ %z = call i1 @test26a()
+ ret i1 %z
+; CHECK: @test26
+; CHECK-NOT: phi i32
+; CHECK: ret i1 %z
+}