diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-04-30 18:16:00 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-04-30 18:16:00 +0000 |
commit | 23b02cd0315625d9d586118abcc972053298d50b (patch) | |
tree | 5d9d5f6566ad26fd5ed58d7f5ee195ee14eb122d /lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | |
parent | 2f8e038b35c06cd130b327433e40d343e1d27244 (diff) |
Use SimplifyDemandedBits on div instructions.
This folds away silly stuff like (a&255)/1000 -> 0.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130614 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineMulDivRem.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 6651387481..b4f4da6fb0 100644 --- a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -320,6 +320,10 @@ Instruction *InstCombiner::commonIDivTransforms(BinaryOperator &I) { } } + // See if we can fold away this div instruction. + if (SimplifyDemandedInstructionBits(I)) + return &I; + // (X - (X rem Y)) / Y -> X / Y; usually originates as ((X / Y) * Y) / Y Value *X = 0, *Z = 0; if (match(Op0, m_Sub(m_Value(X), m_Value(Z)))) { // (X - Z) / Y; Y = Op1 |