diff options
| author | Jim Grosbach <grosbach@apple.com> | 2013-08-16 00:15:20 +0000 |
|---|---|---|
| committer | Jim Grosbach <grosbach@apple.com> | 2013-08-16 00:15:20 +0000 |
| commit | 20e3b9ac30f26fe3135434e3556c1a462e50e113 (patch) | |
| tree | 9ff70d02f083f281cf8b5dc5922bc1f67a39d0fe /llvm/test | |
| parent | 9ee175d8f0975c459a1c90141d69bd78f3ea0047 (diff) | |
| download | bcm5719-llvm-20e3b9ac30f26fe3135434e3556c1a462e50e113.tar.gz bcm5719-llvm-20e3b9ac30f26fe3135434e3556c1a462e50e113.zip | |
InstCombine: Simplify if(x!=0 && x!=-1).
When both constants are positive or both constants are negative,
InstCombine already simplifies comparisons like this, but when
it's exactly zero and -1, the operand sorting ends up reversed
and the pattern fails to match. Handle that special case.
Follow up for rdar://14689217
llvm-svn: 188512
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/and2.ll | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/and2.ll b/llvm/test/Transforms/InstCombine/and2.ll index 504391aa485..e88fd598300 100644 --- a/llvm/test/Transforms/InstCombine/and2.ll +++ b/llvm/test/Transforms/InstCombine/and2.ll @@ -42,3 +42,15 @@ define <4 x i32> @test5(<4 x i32> %A) { %2 = and <4 x i32> <i32 1, i32 2, i32 3, i32 4>, %1 ret <4 x i32> %2 } + +; Check that we combine "if x!=0 && x!=-1" into "if x+1u>1" +define i32 @test6(i64 %x) nounwind { +; CHECK: @test6 +; CHECK-NEXT: add i64 %x, 1 +; CHECK-NEXT: icmp ugt i64 %x.off, 1 + %cmp1 = icmp ne i64 %x, -1 + %not.cmp = icmp ne i64 %x, 0 + %.cmp1 = and i1 %cmp1, %not.cmp + %land.ext = zext i1 %.cmp1 to i32 + ret i32 %land.ext +} |

