diff options
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineMulDivRem.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 5eba463ec0..65a64b8321 100644 --- a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -464,11 +464,11 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { // Udiv ((Lshl x, C1) , C2) -> x / (C2 * 1<<C1); if (ConstantInt *C2 = dyn_cast<ConstantInt>(Op1)) { - Value *X = 0, *C1 = 0; - if (match(Op0, m_LShr(m_Value(X), m_Value(C1))) && C2->getBitWidth() < 65) { - uint64_t NC = cast<ConstantInt>(C2)->getZExtValue() * - (1<< cast<ConstantInt>(C1)->getZExtValue()); - return BinaryOperator::CreateUDiv(X, ConstantInt::get(I.getType(), NC)); + Value *X; + ConstantInt *C1; + if (match(Op0, m_LShr(m_Value(X), m_ConstantInt(C1)))) { + APInt NC = C2->getValue().shl(C1->getZExtValue()); + return BinaryOperator::CreateUDiv(X, Builder->getInt(NC)); } } @@ -545,11 +545,11 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) { // Sdiv ((Ashl x, C1) , C2) -> x / (C2 * 1<<C1); if (ConstantInt *C2 = dyn_cast<ConstantInt>(Op1)) { - Value *X = 0, *C1 = 0; - if (match(Op0, m_AShr(m_Value(X), m_Value(C1))) && C2->getBitWidth() < 65) { - uint64_t NC = cast<ConstantInt>(C2)->getZExtValue() * - (1<< cast<ConstantInt>(C1)->getZExtValue()); - return BinaryOperator::CreateSDiv(X, ConstantInt::get(I.getType(), NC)); + Value *X; + ConstantInt *C1; + if (match(Op0, m_AShr(m_Value(X), m_ConstantInt(C1)))) { + APInt NC = C2->getValue().shl(C1->getZExtValue()); + return BinaryOperator::CreateSDiv(X, Builder->getInt(NC)); } } |