diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-14 15:21:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-14 15:21:58 +0000 |
commit | 8db2cd1fc767086f65b5f93d9c7b4c1924774775 (patch) | |
tree | 273e8c91fb2516b8481fc88b8d031cfeca9f3d43 /test/Transforms | |
parent | 5da60469f9a9513c28c9d715d818f7d789972e90 (diff) | |
download | external_llvm-8db2cd1fc767086f65b5f93d9c7b4c1924774775.zip external_llvm-8db2cd1fc767086f65b5f93d9c7b4c1924774775.tar.gz external_llvm-8db2cd1fc767086f65b5f93d9c7b4c1924774775.tar.bz2 |
make instcombine's instruction sinking more aggressive in the
presence of PHI nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84103 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/InstCombine/sink_instruction.ll | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/test/Transforms/InstCombine/sink_instruction.ll b/test/Transforms/InstCombine/sink_instruction.ll index c46d210..e521de2 100644 --- a/test/Transforms/InstCombine/sink_instruction.ll +++ b/test/Transforms/InstCombine/sink_instruction.ll @@ -3,7 +3,8 @@ ;; This tests that the instructions in the entry blocks are sunk into each ;; arm of the 'if'. -define i32 @foo(i1 %C, i32 %A, i32 %B) { +define i32 @test1(i1 %C, i32 %A, i32 %B) { +; CHECK: @test1 entry: %tmp.2 = sdiv i32 %A, %B ; <i32> [#uses=1] %tmp.9 = add i32 %B, %A ; <i32> [#uses=1] @@ -18,3 +19,38 @@ endif: ; preds = %entry ret i32 %tmp.2 } + +;; PHI use, sink divide before call. +define i32 @test2(i32 %x) nounwind ssp { +; CHECK: @test2 +; CHECK-NOT: sdiv i32 +entry: + br label %bb + +bb: ; preds = %bb2, %entry + %x_addr.17 = phi i32 [ %x, %entry ], [ %x_addr.0, %bb2 ] ; <i32> [#uses=4] + %i.06 = phi i32 [ 0, %entry ], [ %4, %bb2 ] ; <i32> [#uses=1] + %0 = add nsw i32 %x_addr.17, 1 ; <i32> [#uses=1] + %1 = sdiv i32 %0, %x_addr.17 ; <i32> [#uses=1] + %2 = icmp eq i32 %x_addr.17, 0 ; <i1> [#uses=1] + br i1 %2, label %bb1, label %bb2 + +bb1: ; preds = %bb +; CHECK: bb1: +; CHECK-NEXT: add nsw i32 %x_addr.17, 1 +; CHECK-NEXT: sdiv i32 +; CHECK-NEXT: tail call i32 @bar() + %3 = tail call i32 @bar() nounwind ; <i32> [#uses=0] + br label %bb2 + +bb2: ; preds = %bb, %bb1 + %x_addr.0 = phi i32 [ %1, %bb1 ], [ %x_addr.17, %bb ] ; <i32> [#uses=2] + %4 = add nsw i32 %i.06, 1 ; <i32> [#uses=2] + %exitcond = icmp eq i32 %4, 1000000 ; <i1> [#uses=1] + br i1 %exitcond, label %bb4, label %bb + +bb4: ; preds = %bb2 + ret i32 %x_addr.0 +} + +declare i32 @bar() |