diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-12-24 17:31:53 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-12-24 17:31:53 +0000 |
| commit | b16bd77bd239829b9010bb186623183613beeb1d (patch) | |
| tree | 6c50ee398fd75e2879ff623f0b28d5586b65214b /llvm/test/Transforms | |
| parent | 4ee5747fddc9cf0c8ce48b72f58cc4981cded922 (diff) | |
| download | bcm5719-llvm-b16bd77bd239829b9010bb186623183613beeb1d.tar.gz bcm5719-llvm-b16bd77bd239829b9010bb186623183613beeb1d.zip | |
InstCombine: Add a combine that turns (2^n)-1 ^ x back into (2^n)-1 - x iff x is smaller than 2^n and it fuses with a following add.
This was intended to undo the sub canonicalization in cases where it's not profitable, but it also
finds some cases on it's own.
llvm-svn: 147256
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/sub-xor.ll | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/sub-xor.ll b/llvm/test/Transforms/InstCombine/sub-xor.ll index bfa9f408c6f..279e4aca9de 100644 --- a/llvm/test/Transforms/InstCombine/sub-xor.ll +++ b/llvm/test/Transforms/InstCombine/sub-xor.ll @@ -23,3 +23,15 @@ define i32 @test2(i32 %x) nounwind { ; CHECK-NEXT: xor i32 %count, 31 ; CHECK-NEXT: ret } + +define i32 @test3(i32 %x) nounwind { + %and = and i32 %x, 31 + %sub = xor i32 31, %and + %add = add i32 %sub, 42 + ret i32 %add + +; CHECK: @test3 +; CHECK-NEXT: and i32 %x, 31 +; CHECK-NEXT: sub i32 73, %and +; CHECK-NEXT: ret +} |

