Fold ashr -1, X into -1

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4070 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-10-08 16:16:40 +00:00
parent af1b4ad24c
commit 6eaeb5764c

View File

@ -503,6 +503,12 @@ Instruction *InstCombiner::visitShiftInst(Instruction &I) {
return BinaryOperator::create(Instruction::Add, Op0, Op0, I.getName());
}
// shr int -1, X = -1 (for any arithmetic shift rights of ~0)
if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(Op0))
if (I.getOpcode() == Instruction::Shr && CSI->isAllOnesValue())
return ReplaceInstUsesWith(I, CSI);
return 0;
}