diff options
| author | Philip Reames <listmail@philipreames.com> | 2015-10-29 03:19:10 +0000 |
|---|---|---|
| committer | Philip Reames <listmail@philipreames.com> | 2015-10-29 03:19:10 +0000 |
| commit | dbbd77921d93235bbda8c970e6a696318ce37a2b (patch) | |
| tree | 40bce255f0f7bd9abc917059f961595f911c8389 /llvm/test/Transforms/InstSimplify | |
| parent | 846e3e41edc04dbc8fdc14e24420bfe28cdfded3 (diff) | |
| download | bcm5719-llvm-dbbd77921d93235bbda8c970e6a696318ce37a2b.tar.gz bcm5719-llvm-dbbd77921d93235bbda8c970e6a696318ce37a2b.zip | |
[InstSimplify] sgt on i1s also encodes implication
Follow on to http://reviews.llvm.org/D13074, implementing something pointed out by Sanjoy. His truth table from his comment on that bug summarizes things well:
LHS | RHS | LHS >=s RHS | LHS implies RHS
0 | 0 | 1 (0 >= 0) | 1
0 | 1 | 1 (0 >= -1) | 1
1 | 0 | 0 (-1 >= 0) | 0
1 | 1 | 1 (-1 >= -1) | 1
The key point is that an "i1 1" is the value "-1", not "1".
Differential Revision: http://reviews.llvm.org/D13756
llvm-svn: 251597
Diffstat (limited to 'llvm/test/Transforms/InstSimplify')
| -rw-r--r-- | llvm/test/Transforms/InstSimplify/implies.ll | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/implies.ll b/llvm/test/Transforms/InstSimplify/implies.ll index 80b6ac810d0..ac46b8d2828 100644 --- a/llvm/test/Transforms/InstSimplify/implies.ll +++ b/llvm/test/Transforms/InstSimplify/implies.ll @@ -91,3 +91,14 @@ define <4 x i1> @test6(<4 x i1> %a, <4 x i1> %b) { %res = icmp ule <4 x i1> %a, %b ret <4 x i1> %res } + +; X >=(s) Y == X ==> Y (i1 1 becomes -1 for reasoning) +define i1 @test_sge(i32 %length.i, i32 %i) { +; CHECK-LABEL: @test_sge +; CHECK: ret i1 true + %iplus1 = add nsw nuw i32 %i, 1 + %var29 = icmp ult i32 %i, %length.i + %var30 = icmp ult i32 %iplus1, %length.i + %res = icmp sge i1 %var30, %var29 + ret i1 %res +} |

