summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-07-13 21:15:11 +0000
committerChris Lattner <sabre@nondot.org>2008-07-13 21:15:11 +0000
commit70087f31f154156bcb494dd0cf3b7d74c0c8b528 (patch)
tree941f7575cf6cfbfd0c7121e4788c136161a70384 /lib/Transforms/Utils/SimplifyCFG.cpp
parent1347e87c7baa78bd442d7017a8d67bd4fe674e01 (diff)
downloadllvm-70087f31f154156bcb494dd0cf3b7d74c0c8b528.tar.gz
llvm-70087f31f154156bcb494dd0cf3b7d74c0c8b528.tar.bz2
llvm-70087f31f154156bcb494dd0cf3b7d74c0c8b528.tar.xz
simplify logic a bit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53527 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 53725ea76c..1caf1182d5 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1473,9 +1473,15 @@ static bool FoldBranchToCommonDest(BranchInst *BI) {
PBI->setSuccessor(0, OldFalse);
PBI->setSuccessor(1, OldTrue);
}
+
+ Instruction::BinaryOps Opc = Instruction::Shl; // sentinel.
+
+ if (PBI->getSuccessor(0) == TrueDest && FalseDest != BB)
+ Opc = Instruction::Or;
+ else if (PBI->getSuccessor(1) == FalseDest && TrueDest != BB)
+ Opc = Instruction::And;
- if ((PBI->getSuccessor(0) == TrueDest && FalseDest != BB) ||
- (PBI->getSuccessor(1) == FalseDest && TrueDest != BB)) {
+ if (Opc != Instruction::Shl) {
// Clone Cond into the predecessor basic block, and or/and the
// two conditions together.
Instruction *New = Cond->clone();
@@ -1483,13 +1489,8 @@ static bool FoldBranchToCommonDest(BranchInst *BI) {
New->takeName(Cond);
Cond->setName(New->getName()+".old");
- Value *NewCond;
- if (PBI->getSuccessor(0) == TrueDest)
- NewCond = BinaryOperator::CreateOr(PBI->getCondition(), New, "or.cond",
- PBI);
- else
- NewCond = BinaryOperator::CreateOr(PBI->getCondition(), New, "and.cond",
- PBI);
+ Value *NewCond = BinaryOperator::Create(Opc, PBI->getCondition(),
+ New, "or.cond", PBI);
PBI->setCondition(NewCond);
if (PBI->getSuccessor(0) == BB) {
AddPredecessorToBlock(TrueDest, PredBlock, BB);