Fold ashr -1, X into -1

llvm-svn: 4070
This commit is contained in:
Chris Lattner 2002-10-08 16:16:40 +00:00
parent ee5c8a9e8d
commit 2e0fb39d87
1 changed files with 6 additions and 0 deletions

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;
}