diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-05-18 19:30:37 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-05-18 19:30:37 +0000 |
commit | cb9d4667b7159944598c178dbb6568bc20ae069b (patch) | |
tree | 8aec7cbe5952aef278045a8fbfb5600103558ce6 /test/Transforms/InstCombine | |
parent | 688b5103eb4b70410d1ea54bcd8df4ef2f2ff8e8 (diff) | |
download | external_llvm-cb9d4667b7159944598c178dbb6568bc20ae069b.zip external_llvm-cb9d4667b7159944598c178dbb6568bc20ae069b.tar.gz external_llvm-cb9d4667b7159944598c178dbb6568bc20ae069b.tar.bz2 |
isKnownToBeAPowerOfTwo: (X & Y) + Y is a power of 2 or zero if y is also.
This is useful if something that looks like (x & (1 << y)) ? 64 : 32 is
the divisor in a modulo operation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182200 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine')
-rw-r--r-- | test/Transforms/InstCombine/rem.ll | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/rem.ll b/test/Transforms/InstCombine/rem.ll index 450a62a..808d51e 100644 --- a/test/Transforms/InstCombine/rem.ll +++ b/test/Transforms/InstCombine/rem.ll @@ -149,3 +149,17 @@ define i64 @test15(i32 %x, i32 %y) { %urem = urem i64 %zext1, %zext0 ret i64 %urem } + +define i32 @test16(i32 %x, i32 %y) { +; CHECK: @test16 +; CHECK-NEXT: [[SHR:%.*]] = lshr i32 %y, 11 +; CHECK-NEXT: [[AND:%.*]] = and i32 [[SHR]], 4 +; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], 3 +; CHECK-NEXT: [[REM:%.*]] = and i32 [[OR]], %x +; CHECK-NEXT: ret i32 [[REM]] + %shr = lshr i32 %y, 11 + %and = and i32 %shr, 4 + %add = add i32 %and, 4 + %rem = urem i32 %x, %add + ret i32 %rem +} |