diff options
author | Chris Lattner <sabre@nondot.org> | 2011-05-23 00:21:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-05-23 00:21:50 +0000 |
commit | 05cd88656135255b545d24adb51c2ba1b5c8b99e (patch) | |
tree | 53a1eb6bec56af7222ee7474e48071b2af22f2bc /test/Transforms/InstCombine/shift.ll | |
parent | f415d8b64687d4db7e1986b74e9da6cae72c0fd1 (diff) |
Transform any logical shift of a power of two into an exact/NUW shift when
in a known-non-zero context.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131887 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/shift.ll')
-rw-r--r-- | test/Transforms/InstCombine/shift.ll | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/shift.ll b/test/Transforms/InstCombine/shift.ll index bded68ac47..d9ac9cbfe9 100644 --- a/test/Transforms/InstCombine/shift.ll +++ b/test/Transforms/InstCombine/shift.ll @@ -506,3 +506,24 @@ define i32 @test41(i32 %a, i32 %b) nounwind { ; CHECK-NEXT: shl i32 8, %b ; CHECK-NEXT: ret i32 } + +define i32 @test42(i32 %a, i32 %b) nounwind { + %div = lshr i32 4096, %b ; must be exact otherwise we'd divide by zero + %div2 = udiv i32 %a, %div + ret i32 %div2 +; CHECK: @test42 +; CHECK-NEXT: lshr exact i32 4096, %b +} + +define i32 @test43(i32 %a, i32 %b) nounwind { + %div = shl i32 4096, %b ; must be exact otherwise we'd divide by zero + %div2 = udiv i32 %a, %div + ret i32 %div2 +; CHECK: @test43 +; CHECK-NEXT: add i32 %b, 12 +; CHECK-NEXT: lshr +; CHECK-NEXT: ret +} + + + |