diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2016-09-04 20:58:27 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2016-09-04 20:58:27 +0000 |
| commit | c641e9d6ffd76cccfc597c18191308a31a8daff7 (patch) | |
| tree | 44bc3dc0968c6fb145565e6754cef7b7cf7923c3 /llvm/test | |
| parent | 040b10784e24c36d08b099ad42d9bcabeb5a2004 (diff) | |
| download | bcm5719-llvm-c641e9d6ffd76cccfc597c18191308a31a8daff7.tar.gz bcm5719-llvm-c641e9d6ffd76cccfc597c18191308a31a8daff7.zip | |
[InstCombine] allow icmp (and X, C2), C1 folds for splat constant vectors
The code to calculate 'UsesRemoved' could be simplified.
As-is, that code is a victim of PR30273:
https://llvm.org/bugs/show_bug.cgi?id=30273
llvm-svn: 280637
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/icmp.ll | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 9ad8250f66c..73059321a6b 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -1013,15 +1013,29 @@ define i1 @test67(i32 %x) { ret i1 %cmp } -; FIXME: Vectors should fold the same way. +; The test above relies on 3 different folds. +; This test only checks the last of those (icmp ugt -> icmp ne). + define <2 x i1> @test67vec(<2 x i32> %x) { ; CHECK-LABEL: @test67vec( +; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> %x, <i32 96, i32 96> +; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[AND]], zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %and = and <2 x i32> %x, <i32 96, i32 96> + %cmp = icmp ugt <2 x i32> %and, <i32 31, i32 31> + ret <2 x i1> %cmp +} + +; FIXME: Vector constant for the 'and' should use less bits. +define <2 x i1> @test67vec2(<2 x i32> %x) { +; CHECK-LABEL: @test67vec2( ; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> %x, <i32 127, i32 127> ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt <2 x i32> [[AND]], <i32 31, i32 31> ; CHECK-NEXT: ret <2 x i1> [[CMP]] ; %and = and <2 x i32> %x, <i32 127, i32 127> - %cmp = icmp sgt <2 x i32> %and, <i32 31, i32 31> + %cmp = icmp ugt <2 x i32> %and, <i32 31, i32 31> ret <2 x i1> %cmp } @@ -2059,13 +2073,12 @@ define i1 @icmp_and_or_lshr(i32 %x, i32 %y) { ret i1 %ret } -; FIXME: Vectors should fold the same way. define <2 x i1> @icmp_and_or_lshr_vec(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @icmp_and_or_lshr_vec( -; CHECK-NEXT: [[SHF:%.*]] = lshr <2 x i32> %x, %y -; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[SHF]], %x -; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[OR]], <i32 1, i32 1> -; CHECK-NEXT: [[RET:%.*]] = icmp ne <2 x i32> [[AND]], zeroinitializer +; CHECK-NEXT: [[SHF1:%.*]] = shl nuw <2 x i32> <i32 1, i32 1>, %y +; CHECK-NEXT: [[OR2:%.*]] = or <2 x i32> [[SHF1]], <i32 1, i32 1> +; CHECK-NEXT: [[AND3:%.*]] = and <2 x i32> [[OR2]], %x +; CHECK-NEXT: [[RET:%.*]] = icmp ne <2 x i32> [[AND3]], zeroinitializer ; CHECK-NEXT: ret <2 x i1> [[RET]] ; %shf = lshr <2 x i32> %x, %y @@ -2088,13 +2101,10 @@ define i1 @icmp_and_or_lshr_cst(i32 %x) { ret i1 %ret } -; FIXME: Vectors should fold the same way. define <2 x i1> @icmp_and_or_lshr_cst_vec(<2 x i32> %x) { ; CHECK-LABEL: @icmp_and_or_lshr_cst_vec( -; CHECK-NEXT: [[SHF:%.*]] = lshr <2 x i32> %x, <i32 1, i32 1> -; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[SHF]], %x -; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[OR]], <i32 1, i32 1> -; CHECK-NEXT: [[RET:%.*]] = icmp ne <2 x i32> [[AND]], zeroinitializer +; CHECK-NEXT: [[AND1:%.*]] = and <2 x i32> %x, <i32 3, i32 3> +; CHECK-NEXT: [[RET:%.*]] = icmp ne <2 x i32> [[AND1]], zeroinitializer ; CHECK-NEXT: ret <2 x i1> [[RET]] ; %shf = lshr <2 x i32> %x, <i32 1, i32 1> |

