summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-08-30 11:23:20 +0000
committerNadav Rotem <nrotem@apple.com>2012-08-30 11:23:20 +0000
commit639570c3117aaabb0c97b34a9bf05d09f8903ef4 (patch)
treea844659e4411dc7c722bc16c130f349d5d0667b4 /lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
parentc4a32e6596f3974a6c00322db1f5f31ea448bd58 (diff)
downloadllvm-639570c3117aaabb0c97b34a9bf05d09f8903ef4.tar.gz
llvm-639570c3117aaabb0c97b34a9bf05d09f8903ef4.tar.bz2
llvm-639570c3117aaabb0c97b34a9bf05d09f8903ef4.tar.xz
It is illegal to transform (sdiv (ashr X c1) c2) -> (sdiv x (2^c1 * c2)),
because C always rounds towards zero. Thanks Dirk and Ben. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162899 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineMulDivRem.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineMulDivRem.cpp10
1 files changed, 0 insertions, 10 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index 2119115ca7..003dc55a03 100644
--- a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -543,16 +543,6 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
ConstantExpr::getNeg(RHS));
}
- // Sdiv ((Ashl x, C1) , C2) -> x / (C2 * 1<<C1);
- if (ConstantInt *C2 = dyn_cast<ConstantInt>(Op1)) {
- Value *X;
- ConstantInt *C1;
- if (match(Op0, m_AShr(m_Value(X), m_ConstantInt(C1)))) {
- APInt NC = C2->getValue().shl(C1->getLimitedValue(C1->getBitWidth()-1));
- return BinaryOperator::CreateSDiv(X, Builder->getInt(NC));
- }
- }
-
// If the sign bits of both operands are zero (i.e. we can prove they are
// unsigned inputs), turn this into a udiv.
if (I.getType()->isIntegerTy()) {