[llvm-commits] [llvm] r162751 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp test/Transforms/InstCombine/2012-08-28-udiv_ashl.ll
Benjamin Kramer
benny.kra at gmail.com
Tue Aug 28 07:01:20 PDT 2012
On 28.08.2012, at 15:39, Duncan Sands <baldrick at free.fr> wrote:
> Hi Benjamin,
>> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
>> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Tue Aug 28 08:08:13 2012
>> @@ -464,11 +464,11 @@
>>
>> // 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());
>
> shouldn't this use getLimitedValue just in case?
Thanks for noticing, fixed in r162755.
- Ben
>
>> + return BinaryOperator::CreateUDiv(X, Builder->getInt(NC));
>> }
>> }
>>
>> @@ -545,11 +545,11 @@
>>
>> // 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)))) {
>
> Likewise.
>
> Ciao, Duncan.
>
>> + APInt NC = C2->getValue().shl(C1->getZExtValue());
>> + return BinaryOperator::CreateSDiv(X, Builder->getInt(NC));
>> }
>> }
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list