diff options
| author | Craig Topper <craig.topper@intel.com> | 2017-08-14 18:49:39 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2017-08-14 18:49:39 +0000 |
| commit | 58def1e1f2248102ec2d282cfcc60f1278e4dbfc (patch) | |
| tree | 5b4bb08a2667eb6877a50dd3a729f45d1b568317 | |
| parent | 302dc8bccffe6a047f22fac456cf2bb4871beedc (diff) | |
| download | bcm5719-llvm-58def1e1f2248102ec2d282cfcc60f1278e4dbfc.tar.gz bcm5719-llvm-58def1e1f2248102ec2d282cfcc60f1278e4dbfc.zip | |
[InstSimplify] Add some tests cases for selects with bittests hidden in ugt/ult/uge/ule compares. NFC
llvm-svn: 310868
| -rw-r--r-- | llvm/test/Transforms/InstSimplify/select.ll | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/select.ll b/llvm/test/Transforms/InstSimplify/select.ll index f81dd3f261d..e9c94170a94 100644 --- a/llvm/test/Transforms/InstSimplify/select.ll +++ b/llvm/test/Transforms/InstSimplify/select.ll @@ -160,6 +160,64 @@ define <2 x i8> @test11vec(<2 x i8> %X) { ret <2 x i8> %sel } +; TODO: we should be able to simplify this +define i32 @test12(i32 %X) { +; CHECK-LABEL: @test12( +; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[X:%.*]], 4 +; CHECK-NEXT: [[AND:%.*]] = and i32 [[X]], 3 +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[AND]] +; CHECK-NEXT: ret i32 [[COND]] +; + %cmp = icmp ult i32 %X, 4 + %and = and i32 %X, 3 + %cond = select i1 %cmp, i32 %X, i32 %and + ret i32 %cond +} + +; Same as above, but the compare isn't canonical +; TODO: we should be able to simplify this +define i32 @test12noncanon(i32 %X) { +; CHECK-LABEL: @test12noncanon( +; CHECK-NEXT: [[CMP:%.*]] = icmp ule i32 [[X:%.*]], 3 +; CHECK-NEXT: [[AND:%.*]] = and i32 [[X]], 3 +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[AND]] +; CHECK-NEXT: ret i32 [[COND]] +; + %cmp = icmp ule i32 %X, 3 + %and = and i32 %X, 3 + %cond = select i1 %cmp, i32 %X, i32 %and + ret i32 %cond +} + +; TODO: we should be able to simplify this +define i32 @test13(i32 %X) { +; CHECK-LABEL: @test13( +; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[X:%.*]], 3 +; CHECK-NEXT: [[AND:%.*]] = and i32 [[X]], 3 +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[AND]], i32 [[X]] +; CHECK-NEXT: ret i32 [[COND]] +; + %cmp = icmp ugt i32 %X, 3 + %and = and i32 %X, 3 + %cond = select i1 %cmp, i32 %and, i32 %X + ret i32 %cond +} + +; Same as above, but the compare isn't canonical +; TODO: we should be able to simplify this +define i32 @test13noncanon(i32 %X) { +; CHECK-LABEL: @test13noncanon( +; CHECK-NEXT: [[CMP:%.*]] = icmp uge i32 [[X:%.*]], 4 +; CHECK-NEXT: [[AND:%.*]] = and i32 [[X]], 3 +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[AND]], i32 [[X]] +; CHECK-NEXT: ret i32 [[COND]] +; + %cmp = icmp uge i32 %X, 4 + %and = and i32 %X, 3 + %cond = select i1 %cmp, i32 %and, i32 %X + ret i32 %cond +} + define i32 @select_icmp_and_8_eq_0_or_8(i32 %x) { ; CHECK-LABEL: @select_icmp_and_8_eq_0_or_8( ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, 8 |

