X % -1 == X % 1 == 0

llvm-svn: 12520
This commit is contained in:
Chris Lattner 2004-03-26 16:11:24 +00:00
parent 57c67b06e9
commit 56b5051428
1 changed files with 2 additions and 0 deletions

View File

@ -808,6 +808,8 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) {
if (ConstantInt *RHS = dyn_cast<ConstantInt>(I.getOperand(1))) {
if (RHS->equalsInt(1)) // X % 1 == 0
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
if (RHS->isAllOnesValue()) // X % -1 == 0
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
// Check to see if this is an unsigned remainder with an exact power of 2,
// if so, convert to a bitwise and.