mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-24 08:33:39 +00:00
simplify (x+c)^signbit as (x+c+signbit), pointed out by PR1288. This implements
test/Transforms/InstCombine/xor.ll:test28 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35584 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7a32bc9b9b
commit
5c6e2db0c4
@ -4005,7 +4005,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||||||
return BinaryOperator::createOr(Op0NotVal, NotY);
|
return BinaryOperator::createOr(Op0NotVal, NotY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConstantInt *Op0CI = dyn_cast<ConstantInt>(Op0I->getOperand(1)))
|
if (ConstantInt *Op0CI = dyn_cast<ConstantInt>(Op0I->getOperand(1)))
|
||||||
if (Op0I->getOpcode() == Instruction::Add) {
|
if (Op0I->getOpcode() == Instruction::Add) {
|
||||||
// ~(X-c) --> (-c-1)-X
|
// ~(X-c) --> (-c-1)-X
|
||||||
@ -4015,6 +4015,12 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
|||||||
ConstantExpr::getSub(NegOp0CI,
|
ConstantExpr::getSub(NegOp0CI,
|
||||||
ConstantInt::get(I.getType(), 1)),
|
ConstantInt::get(I.getType(), 1)),
|
||||||
Op0I->getOperand(0));
|
Op0I->getOperand(0));
|
||||||
|
} else if (RHS->getValue().isMinSignedValue()) {
|
||||||
|
// (X + C) ^ signbit -> (X + C + signbit)
|
||||||
|
Constant *C = ConstantInt::get(RHS->getValue() + Op0CI->getValue());
|
||||||
|
return BinaryOperator::createAdd(Op0I->getOperand(0), C);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (Op0I->getOpcode() == Instruction::Or) {
|
} else if (Op0I->getOpcode() == Instruction::Or) {
|
||||||
// (X|C1)^C2 -> X^(C1|C2) iff X&~C1 == 0
|
// (X|C1)^C2 -> X^(C1|C2) iff X&~C1 == 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user