diff options
| author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-02-01 16:34:55 +0000 |
|---|---|---|
| committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-02-01 16:34:55 +0000 |
| commit | e0e5795f6b9d2b903e60d968a8c9dbcc7972d2f4 (patch) | |
| tree | 7c9ad3b6312a5ba83234d9309a62b4d28657061c /llvm/test/Transforms | |
| parent | ca931efc21c5791f90e29eb8fa7690db6769fa67 (diff) | |
| download | bcm5719-llvm-e0e5795f6b9d2b903e60d968a8c9dbcc7972d2f4.tar.gz bcm5719-llvm-e0e5795f6b9d2b903e60d968a8c9dbcc7972d2f4.zip | |
[InstCombine] Allow InstCombine to merge adjacent guards
Summary:
If there are two adjacent guards with different conditions, we can
remove one of them and include its condition into the condition of
another one. This patch allows InstCombine to merge them by the
following pattern:
guard(a); guard(b) -> guard(a & b).
Reviewers: reames, apilipenko, igor-laevsky, anna, sanjoy
Reviewed By: sanjoy
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D29378
llvm-svn: 293778
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/call-guard.ll | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/llvm/test/Transforms/InstCombine/call-guard.ll b/llvm/test/Transforms/InstCombine/call-guard.ll index 18da465e606..9664467f914 100644 --- a/llvm/test/Transforms/InstCombine/call-guard.ll +++ b/llvm/test/Transforms/InstCombine/call-guard.ll @@ -2,8 +2,8 @@ declare void @llvm.experimental.guard(i1, ...) -define void @test_guard_adjacent(i1 %A) { -; CHECK-LABEL: @test_guard_adjacent( +define void @test_guard_adjacent_same_cond(i1 %A) { +; CHECK-LABEL: @test_guard_adjacent_same_cond( ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %A) [ "deopt"() ] ; CHECK-NEXT: ret void call void(i1, ...) @llvm.experimental.guard( i1 %A )[ "deopt"() ] @@ -19,12 +19,14 @@ define void @test_guard_adjacent(i1 %A) { ret void } -define void @test_guard_adjacent_neg(i1 %A, i1 %B) { -; CHECK-LABEL: @test_guard_adjacent_neg( -; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %A) [ "deopt"() ] -; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %B) [ "deopt"() ] +define void @test_guard_adjacent_diff_cond(i1 %A, i1 %B, i1 %C) { +; CHECK-LABEL: @test_guard_adjacent_diff_cond( +; CHECK-NEXT: %1 = and i1 %A, %B +; CHECK-NEXT: %2 = and i1 %1, %C +; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %2, i32 123) [ "deopt"() ] ; CHECK-NEXT: ret void - call void(i1, ...) @llvm.experimental.guard( i1 %A )[ "deopt"() ] - call void(i1, ...) @llvm.experimental.guard( i1 %B )[ "deopt"() ] + call void(i1, ...) @llvm.experimental.guard( i1 %A, i32 123 )[ "deopt"() ] + call void(i1, ...) @llvm.experimental.guard( i1 %B, i32 456 )[ "deopt"() ] + call void(i1, ...) @llvm.experimental.guard( i1 %C, i32 789 )[ "deopt"() ] ret void } |

