mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 05:24:01 +00:00
Combine not (not X) -> X
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2493 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -57,7 +57,7 @@ namespace {
|
|||||||
// I - Change was made, I is still valid
|
// I - Change was made, I is still valid
|
||||||
// otherwise - Change was made, replace I with returned instruction
|
// otherwise - Change was made, replace I with returned instruction
|
||||||
//
|
//
|
||||||
|
Instruction *visitNot(UnaryOperator *I);
|
||||||
Instruction *visitAdd(BinaryOperator *I);
|
Instruction *visitAdd(BinaryOperator *I);
|
||||||
Instruction *visitSub(BinaryOperator *I);
|
Instruction *visitSub(BinaryOperator *I);
|
||||||
Instruction *visitMul(BinaryOperator *I);
|
Instruction *visitMul(BinaryOperator *I);
|
||||||
@ -78,6 +78,19 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Instruction *InstCombiner::visitNot(UnaryOperator *I) {
|
||||||
|
if (I->use_empty()) return 0; // Don't fix dead instructions...
|
||||||
|
|
||||||
|
// not (not X) = X
|
||||||
|
if (Instruction *Op = dyn_cast<Instruction>(I->getOperand(0)))
|
||||||
|
if (Op->getOpcode() == Instruction::Not) {
|
||||||
|
AddUsesToWorkList(I); // Add all modified instrs to worklist
|
||||||
|
I->replaceAllUsesWith(Op->getOperand(0));
|
||||||
|
return I;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Make sure that this instruction has a constant on the right hand side if it
|
// Make sure that this instruction has a constant on the right hand side if it
|
||||||
// has any constant arguments. If not, fix it an return true.
|
// has any constant arguments. If not, fix it an return true.
|
||||||
|
Reference in New Issue
Block a user