summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-06-13 05:43:29 +0000
committerManman Ren <mren@apple.com>2012-06-13 05:43:29 +0000
commitee28e0fdd1955d9fe7acc05b3250ceee759ac3c6 (patch)
tree7e88f8e1466aedaf73e9643afdfb6a9e88400701 /test
parent764dc754fe52c3a61363fad341b68be397103668 (diff)
downloadllvm-ee28e0fdd1955d9fe7acc05b3250ceee759ac3c6.tar.gz
llvm-ee28e0fdd1955d9fe7acc05b3250ceee759ac3c6.tar.bz2
llvm-ee28e0fdd1955d9fe7acc05b3250ceee759ac3c6.tar.xz
SimplifyCFG: fold unconditional branch to its predecessor if profitable.
This patch extends FoldBranchToCommonDest to fold unconditional branches. For unconditional branches, we fold them if it is easy to update the phi nodes in the common successors. rdar://10554090 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158392 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/SimplifyCFG/branch-fold.ll33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyCFG/branch-fold.ll b/test/Transforms/SimplifyCFG/branch-fold.ll
index 2b29681191..70c5fb5db2 100644
--- a/test/Transforms/SimplifyCFG/branch-fold.ll
+++ b/test/Transforms/SimplifyCFG/branch-fold.ll
@@ -17,3 +17,36 @@ b:
c:
ret void
}
+
+; rdar://10554090
+define zeroext i1 @test2(i64 %i0, i64 %i1) nounwind uwtable readonly ssp {
+entry:
+; CHECK: test2
+; CHECK: br i1
+ %and.i.i = and i64 %i0, 281474976710655
+ %and.i11.i = and i64 %i1, 281474976710655
+ %or.cond = icmp eq i64 %and.i.i, %and.i11.i
+ br i1 %or.cond, label %c, label %a
+
+a:
+; CHECK: br
+ %shr.i4.i = lshr i64 %i0, 48
+ %and.i5.i = and i64 %shr.i4.i, 32767
+ %shr.i.i = lshr i64 %i1, 48
+ %and.i2.i = and i64 %shr.i.i, 32767
+ %cmp9.i = icmp ult i64 %and.i5.i, %and.i2.i
+ br i1 %cmp9.i, label %c, label %b
+
+b:
+; CHECK-NOT: br
+ %shr.i13.i9 = lshr i64 %i1, 48
+ %and.i14.i10 = and i64 %shr.i13.i9, 32767
+ %shr.i.i11 = lshr i64 %i0, 48
+ %and.i11.i12 = and i64 %shr.i.i11, 32767
+ %phitmp = icmp uge i64 %and.i14.i10, %and.i11.i12
+ br label %c
+
+c:
+ %o2 = phi i1 [ false, %a ], [ %phitmp, %b ], [ false, %entry ]
+ ret i1 %o2
+}