mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 01:24:30 +00:00
Implement Transforms/InstCombine/xor.ll:test19
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1002,15 +1002,26 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
|
|||||||
return Changed ? &I : 0;
|
return Changed ? &I : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XorSelf - Implements: X ^ X --> 0
|
||||||
|
struct XorSelf {
|
||||||
|
Value *RHS;
|
||||||
|
XorSelf(Value *rhs) : RHS(rhs) {}
|
||||||
|
bool shouldApply(Value *LHS) const { return LHS == RHS; }
|
||||||
|
Instruction *apply(BinaryOperator &Xor) const {
|
||||||
|
return &Xor;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
||||||
bool Changed = SimplifyCommutative(I);
|
bool Changed = SimplifyCommutative(I);
|
||||||
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
|
||||||
|
|
||||||
// xor X, X = 0
|
// xor X, X = 0, even if X is nested in a sequence of Xor's.
|
||||||
if (Op0 == Op1)
|
if (Instruction *Result = AssociativeOpt(I, XorSelf(Op1))) {
|
||||||
|
assert(Result == &I && "AssociativeOpt didn't work?");
|
||||||
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
|
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
|
||||||
|
}
|
||||||
|
|
||||||
if (ConstantIntegral *RHS = dyn_cast<ConstantIntegral>(Op1)) {
|
if (ConstantIntegral *RHS = dyn_cast<ConstantIntegral>(Op1)) {
|
||||||
// xor X, 0 == X
|
// xor X, 0 == X
|
||||||
|
Reference in New Issue
Block a user