diff options
| author | Chris Lattner <sabre@nondot.org> | 2002-05-06 17:03:21 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2002-05-06 17:03:21 +0000 |
| commit | 5d6bec5e267e5c20ae32fd36e9d6e13012070ee4 (patch) | |
| tree | b0649e98fa1be37115175e2b2c113c05d5f4054b /llvm/lib/Transforms | |
| parent | 679da03275ea0cc34f833210e0a33986f316ba79 (diff) | |
| download | bcm5719-llvm-5d6bec5e267e5c20ae32fd36e9d6e13012070ee4.tar.gz bcm5719-llvm-5d6bec5e267e5c20ae32fd36e9d6e13012070ee4.zip | |
Combine not (not X) -> X
llvm-svn: 2493
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 9679a2b6aab..0c089120ead 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -57,7 +57,7 @@ namespace { // I - Change was made, I is still valid // otherwise - Change was made, replace I with returned instruction // - + Instruction *visitNot(UnaryOperator *I); Instruction *visitAdd(BinaryOperator *I); Instruction *visitSub(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 // has any constant arguments. If not, fix it an return true. |

