mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-18 12:29:21 +00:00
Fold (X|C1)^C2 -> X^(C1|C2) when possible. This implements
InstCombine/or.ll:test23. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26385 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
80e2065565
commit
02bd1b3e94
@ -2846,6 +2846,20 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
||||
ConstantInt::get(I.getType(), 1)),
|
||||
Op0I->getOperand(0));
|
||||
}
|
||||
} else if (Op0I->getOpcode() == Instruction::Or) {
|
||||
// (X|C1)^C2 -> X^(C1|C2) iff X&~C1 == 0
|
||||
if (MaskedValueIsZero(Op0I->getOperand(0), Op0CI->getZExtValue())) {
|
||||
Constant *NewRHS = ConstantExpr::getOr(Op0CI, RHS);
|
||||
// Anything in both C1 and C2 is known to be zero, remove it from
|
||||
// NewRHS.
|
||||
Constant *CommonBits = ConstantExpr::getAnd(Op0CI, RHS);
|
||||
NewRHS = ConstantExpr::getAnd(NewRHS,
|
||||
ConstantExpr::getNot(CommonBits));
|
||||
WorkList.push_back(Op0I);
|
||||
I.setOperand(0, Op0I->getOperand(0));
|
||||
I.setOperand(1, NewRHS);
|
||||
return &I;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user