[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
Tue Dec 4 09:48:08 PST 2012


Hi, Pete:

  you are right. This lurking problem was fixed and committed last night.

Thanks
Shuxin

On 12/4/12 8:01 AM, Pete Couperus wrote:
> Hi Shuxin,
>
> +    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);
> +    }
>
> Maybe I'm missing something, but shouldn't the
> BinaryOperator::CreateLShr be Create[AL]Shr depending on the type you
> started with, not unconditionally CreateLShr?
>
> +define i32 @test60(i32 %x) {
> +  %shr = ashr i32 %x, 4
> +  %shl = shl i32 %shr, 1
> +  %or = or i32 %shl, 1
> +  ret i32 %or
> +; CHECK: @test60
> +; CHECK: lshr i32 %x, 3
> +}
>
> I would expect this to be ashr i32 %x, 3?
>
> Pete




More information about the llvm-commits mailing list