[llvm-commits] [llvm] r169182 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombine.h lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp test/Transforms/InstCombine/2010-11-01-lshr-mask.ll test/Transforms/InstCombine/shift.ll test/Transforms/InstCombine/signext.ll

Shuxin Yang shuxin.llvm at gmail.com
Mon Dec 10 15:39:34 PST 2012


Hi, Eli:

   Thank you for the feedback. See the interleaving text.

On 12/10/12 2:38 PM, Eli Friedman wrote:
> On Mon, Dec 3, 2012 at 4:04 PM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:
>> +  Value *VarX = Shr->getOperand(0);
>> +  Type *Ty = VarX->getType();
>> +
>> +  APInt BitMask1(Ty->getIntegerBitWidth(), (uint64_t)-1);
>> +  APInt BitMask2(Ty->getIntegerBitWidth(), (uint64_t)-1);
> APInt::getAllOnesValue().  (As-is, this isn't right for bit-widths >= 64.)
You aright. APInt::getAllOnesValue() was the function I were looking for.
I didn't find one. So, I try to use following function as alternative. 
But somehow
I misread the default value of 3rd parameter. I will fix the problem and 
test it
tomorrow.

APInt BitMask1(Ty->getIntegerBitWidth(), (uint64_t)-1, *TRUE*);


>
>> +    BinaryOperator *New;
>> +    if (ShrAmt < ShlAmt) {
>> +      Constant *Amt = ConstantInt::get(VarX->getType(), ShlAmt - ShrAmt);
>> +      New = BinaryOperator::CreateShl(VarX, Amt);
>> +      BinaryOperator *Orig = cast<BinaryOperator>(Shl);
>> +      New->setHasNoSignedWrap(Orig->hasNoSignedWrap());
>> +      New->setHasNoUnsignedWrap(Orig->hasNoUnsignedWrap());
>> +    } else {
>> +      Constant *Amt = ConstantInt::get(VarX->getType(), ShrAmt - ShlAmt);
>> +      New = BinaryOperator::CreateLShr(VarX, Amt);
>> +    }
> Can we propagate the "exact" bit from the original shr?
I'm not sure this question. Could you please elaborate?




More information about the llvm-commits mailing list