diff options
| author | Craig Topper <craig.topper@gmail.com> | 2017-03-22 04:03:53 +0000 | 
|---|---|---|
| committer | Craig Topper <craig.topper@gmail.com> | 2017-03-22 04:03:53 +0000 | 
| commit | 07f2915ad8c6e72c3a0185db78b55b65ab83c123 (patch) | |
| tree | 473f5a6ff847de5b60989a72d14aea2d2076e5ae /llvm/test/Transforms/InstCombine | |
| parent | 7532d3790f5fd0919dbad401b3f952b37c601a2a (diff) | |
| download | bcm5719-llvm-07f2915ad8c6e72c3a0185db78b55b65ab83c123.tar.gz bcm5719-llvm-07f2915ad8c6e72c3a0185db78b55b65ab83c123.zip  | |
[InstCombine] Teach SimplifyDemandedUseBits to shrink Constants on the left side of subtracts
Summary: Subtracts can have constants on the left side, but we don't shrink them based on demanded bits. This patch fixes that to match the right hand side.
Reviewers: davide, majnemer, spatel, sanjoy, hfinkel
Reviewed By: spatel
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D31119
llvm-svn: 298478
Diffstat (limited to 'llvm/test/Transforms/InstCombine')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/sub.ll | 43 | 
1 files changed, 43 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/sub.ll b/llvm/test/Transforms/InstCombine/sub.ll index b756f6a571e..03946c7dbe6 100644 --- a/llvm/test/Transforms/InstCombine/sub.ll +++ b/llvm/test/Transforms/InstCombine/sub.ll @@ -701,3 +701,46 @@ define i8 @bool_sext_sub_nuw(i8 %x, i1 %y) {    ret i8 %sub  } +define i32 @test49(i32 %X) { +; CHECK-LABEL: @test49( +; CHECK-NEXT:    [[SUB:%.*]] = sub i32 1, [[X:%.*]] +; CHECK-NEXT:    [[RES:%.*]] = and i32 [[SUB]], 64 +; CHECK-NEXT:    ret i32 [[RES]] +; +  %sub = sub i32 129, %X +  %res = and i32 %sub, 64 +  ret i32 %res +} + +define i32 @test50(i32 %X) { +; CHECK-LABEL: @test50( +; CHECK-NEXT:    [[SUB:%.*]] = sub i32 1, [[X:%.*]] +; CHECK-NEXT:    [[RES:%.*]] = and i32 [[SUB]], 127 +; CHECK-NEXT:    ret i32 [[RES]] +; +  %sub = sub i32 129, %X +  %res = and i32 %sub, 127 +  ret i32 %res +} + +define i32 @test51(i32 %X) { +; CHECK-LABEL: @test51( +; CHECK-NEXT:    [[SUB:%.*]] = sub i32 126, [[X:%.*]] +; CHECK-NEXT:    [[RES:%.*]] = and i32 [[SUB]], 64 +; CHECK-NEXT:    ret i32 [[RES]] +; +  %sub = sub i32 254, %X +  %res = and i32 %sub, 64 +  ret i32 %res +} + +define i32 @test52(i32 %X) { +; CHECK-LABEL: @test52( +; CHECK-NEXT:    [[SUB:%.*]] = sub i32 126, [[X:%.*]] +; CHECK-NEXT:    [[RES:%.*]] = and i32 [[SUB]], 127 +; CHECK-NEXT:    ret i32 [[RES]] +; +  %sub = sub i32 254, %X +  %res = and i32 %sub, 127 +  ret i32 %res +}  | 

