mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-10 08:40:41 +00:00
Instcombine X/-1 --> 0-X
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13172 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
db05858ba1
commit
83a2e6e4a1
@ -849,11 +849,15 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
|
||||
}
|
||||
|
||||
Instruction *InstCombiner::visitDiv(BinaryOperator &I) {
|
||||
// div X, 1 == X
|
||||
if (ConstantInt *RHS = dyn_cast<ConstantInt>(I.getOperand(1))) {
|
||||
// div X, 1 == X
|
||||
if (RHS->equalsInt(1))
|
||||
return ReplaceInstUsesWith(I, I.getOperand(0));
|
||||
|
||||
// div X, -1 == -X
|
||||
if (RHS->isAllOnesValue())
|
||||
return BinaryOperator::createNeg(I.getOperand(0));
|
||||
|
||||
// Check to see if this is an unsigned division with an exact power of 2,
|
||||
// if so, convert to a right shift.
|
||||
if (ConstantUInt *C = dyn_cast<ConstantUInt>(RHS))
|
||||
|
Loading…
x
Reference in New Issue
Block a user