mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-21 03:32:21 +00:00
Implement rem.ll:test[7-9] and PR712
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26415 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c9c85c4768
commit
9794392781
@ -1867,12 +1867,28 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) {
|
|||||||
if (isPowerOf2_64(C->getValue()))
|
if (isPowerOf2_64(C->getValue()))
|
||||||
return BinaryOperator::createAnd(Op0, SubOne(C));
|
return BinaryOperator::createAnd(Op0, SubOne(C));
|
||||||
|
|
||||||
if (SelectInst *SI = dyn_cast<SelectInst>(Op0))
|
if (Instruction *Op0I = dyn_cast<Instruction>(Op0)) {
|
||||||
|
if (SelectInst *SI = dyn_cast<SelectInst>(Op0I)) {
|
||||||
if (Instruction *R = FoldOpIntoSelect(I, SI, this))
|
if (Instruction *R = FoldOpIntoSelect(I, SI, this))
|
||||||
return R;
|
return R;
|
||||||
if (isa<PHINode>(Op0))
|
} else if (isa<PHINode>(Op0I)) {
|
||||||
if (Instruction *NV = FoldOpIntoPhi(I))
|
if (Instruction *NV = FoldOpIntoPhi(I))
|
||||||
return NV;
|
return NV;
|
||||||
|
} else if (Op0I->getOpcode() == Instruction::Mul) {
|
||||||
|
// X*C1%C2 --> 0 iff C1%C2 == 0
|
||||||
|
if (ConstantInt *MulRHS = dyn_cast<ConstantInt>(Op0I->getOperand(1))) {
|
||||||
|
if (ConstantExpr::getRem(MulRHS, RHS)->isNullValue())
|
||||||
|
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
|
||||||
|
}
|
||||||
|
} else if (Op0I->getOpcode() == Instruction::Shl) {
|
||||||
|
// (X<<C1)%C2 --> 0 iff (1<<C1)%C2 == 0
|
||||||
|
if (Constant *ShRHS = dyn_cast<Constant>(Op0I->getOperand(1))) {
|
||||||
|
ShRHS = ConstantExpr::getShl(ConstantInt::get(I.getType(), 1), ShRHS);
|
||||||
|
if (ConstantExpr::getRem(ShRHS, RHS)->isNullValue())
|
||||||
|
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Instruction *RHSI = dyn_cast<Instruction>(I.getOperand(1))) {
|
if (Instruction *RHSI = dyn_cast<Instruction>(I.getOperand(1))) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user