diff options
author | Chris Lattner <sabre@nondot.org> | 2003-06-04 04:46:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-06-04 04:46:00 +0000 |
commit | c4d10ebcd7f28cdea265483b7231c3a5ca9e6485 (patch) | |
tree | 1a1bf993573a4bb33220aeaf3e308b0330a17f8c /lib | |
parent | 5feab1631f11c8709e535c239081815c2c2786a8 (diff) | |
download | external_llvm-c4d10ebcd7f28cdea265483b7231c3a5ca9e6485.zip external_llvm-c4d10ebcd7f28cdea265483b7231c3a5ca9e6485.tar.gz external_llvm-c4d10ebcd7f28cdea265483b7231c3a5ca9e6485.tar.bz2 |
Implement combination of boolean not with branch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6599 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 21c58b6..2a5856a 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -76,6 +76,7 @@ namespace { Instruction *visitPHINode(PHINode &PN); Instruction *visitGetElementPtrInst(GetElementPtrInst &GEP); Instruction *visitAllocationInst(AllocationInst &AI); + Instruction *visitBranchInst(BranchInst &BI); // visitInstruction - Specify what to return for unhandled instructions... Instruction *visitInstruction(Instruction &I) { return 0; } @@ -1061,6 +1062,19 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) { return 0; } +Instruction *InstCombiner::visitBranchInst(BranchInst &BI) { + // Change br (not X), label True, label False to: br X, label False, True + if (BI.isConditional() && BinaryOperator::isNot(BI.getCondition())) { + BasicBlock *TrueDest = BI.getSuccessor(0); + BasicBlock *FalseDest = BI.getSuccessor(1); + // Swap Destinations and condition... + BI.setCondition(BinaryOperator::getNotArgument(cast<BinaryOperator>(BI.getCondition()))); + BI.setSuccessor(0, FalseDest); + BI.setSuccessor(1, TrueDest); + return &BI; + } + return 0; +} void InstCombiner::removeFromWorkList(Instruction *I) { |