diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-06 22:05:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-06 22:05:31 +0000 |
commit | 6e57b152283cbf1b4a9a75e9b1fb1b6d6eb5f6d6 (patch) | |
tree | 7fa41e33b08add60afcfa09b3375c663bd6653f4 /llvm/test/Transforms/InstSimplify/reassociate.ll | |
parent | 9c70414551ec49955d3777bb294e1ebeb7d5da6a (diff) | |
download | bcm5719-llvm-6e57b152283cbf1b4a9a75e9b1fb1b6d6eb5f6d6.tar.gz bcm5719-llvm-6e57b152283cbf1b4a9a75e9b1fb1b6d6eb5f6d6.zip |
teach instsimplify to transform (X / Y) * Y to X
when the div is an exact udiv.
llvm-svn: 124994
Diffstat (limited to 'llvm/test/Transforms/InstSimplify/reassociate.ll')
-rw-r--r-- | llvm/test/Transforms/InstSimplify/reassociate.ll | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/reassociate.ll b/llvm/test/Transforms/InstSimplify/reassociate.ll index 928442ac56c..3c8169e5e28 100644 --- a/llvm/test/Transforms/InstSimplify/reassociate.ll +++ b/llvm/test/Transforms/InstSimplify/reassociate.ll @@ -137,6 +137,7 @@ define i32 @sdiv5(i32 %x, i32 %y) { ; CHECK: ret i32 %x } + define i32 @udiv1(i32 %x, i32 %y) { ; CHECK: @udiv1 ; (no overflow X * Y) / Y -> X @@ -164,3 +165,22 @@ define i32 @udiv3(i32 %x, i32 %y) { ret i32 %div ; CHECK: ret i32 0 } + +define i32 @udiv4(i32 %x, i32 %y) { +; CHECK: @udiv4 +; (X / Y) * Y -> X if the division is exact + %div = udiv exact i32 %x, %y + %mul = mul i32 %div, %y + ret i32 %mul +; CHECK: ret i32 %x +} + +define i32 @udiv5(i32 %x, i32 %y) { +; CHECK: @udiv5 +; Y * (X / Y) -> X if the division is exact + %div = udiv exact i32 %x, %y + %mul = mul i32 %y, %div + ret i32 %mul +; CHECK: ret i32 %x +} + |