diff options
| author | Craig Topper <craig.topper@intel.com> | 2017-08-10 01:02:02 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2017-08-10 01:02:02 +0000 |
| commit | ba69187988ad87aed456608f36febb6f05047370 (patch) | |
| tree | 268f2db91bd05297fb96299735039c94ddcf016b /llvm/test/Transforms/InstSimplify/select.ll | |
| parent | c8fbf6ffeaeb4fc9a2b5fcd6c993d64bcbb52818 (diff) | |
| download | bcm5719-llvm-ba69187988ad87aed456608f36febb6f05047370.tar.gz bcm5719-llvm-ba69187988ad87aed456608f36febb6f05047370.zip | |
[InstSimplify] Add test cases that show that simplifySelectWithICmpCond doesn't work with non-canonical comparisons.
llvm-svn: 310542
Diffstat (limited to 'llvm/test/Transforms/InstSimplify/select.ll')
| -rw-r--r-- | llvm/test/Transforms/InstSimplify/select.ll | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/select.ll b/llvm/test/Transforms/InstSimplify/select.ll index cb2502cf63c..f81dd3f261d 100644 --- a/llvm/test/Transforms/InstSimplify/select.ll +++ b/llvm/test/Transforms/InstSimplify/select.ll @@ -46,6 +46,21 @@ define i32 @test4(i32 %X) { ret i32 %cond } +; Same as above, but the compare isn't canonical +; TODO: we should be able to simplify this +define i32 @test4noncanon(i32 %X) { +; CHECK-LABEL: @test4noncanon( +; CHECK-NEXT: [[CMP:%.*]] = icmp sle i32 [[X:%.*]], -1 +; CHECK-NEXT: [[OR:%.*]] = or i32 [[X]], -2147483648 +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[OR]] +; CHECK-NEXT: ret i32 [[COND]] +; + %cmp = icmp sle i32 %X, -1 + %or = or i32 %X, -2147483648 + %cond = select i1 %cmp, i32 %X, i32 %or + ret i32 %cond +} + define i32 @test5(i32 %X) { ; CHECK-LABEL: @test5( ; CHECK-NEXT: ret i32 %X @@ -98,6 +113,21 @@ define i32 @test9(i32 %X) { ret i32 %cond } +; Same as above, but the compare isn't canonical +; TODO: we should be able to simplify this +define i32 @test9noncanon(i32 %X) { +; CHECK-LABEL: @test9noncanon( +; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[X:%.*]], 0 +; CHECK-NEXT: [[OR:%.*]] = or i32 [[X]], -2147483648 +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[OR]], i32 [[X]] +; CHECK-NEXT: ret i32 [[COND]] +; + %cmp = icmp sge i32 %X, 0 + %or = or i32 %X, -2147483648 + %cond = select i1 %cmp, i32 %or, i32 %X + ret i32 %cond +} + define i32 @test10(i32 %X) { ; CHECK-LABEL: @test10( ; CHECK-NEXT: ret i32 %X |

