summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-13 08:12:19 +0000
committerChris Lattner <sabre@nondot.org>2010-12-13 08:12:19 +0000
commitfb836f8c1a19a5eaf09580e48014917a7fe43595 (patch)
tree095aa60e7a2635bacf607f43dfb9d7b144405404 /llvm/lib
parent78494f50e5b2f17b44dcd1462d01d43255a08341 (diff)
downloadbcm5719-llvm-fb836f8c1a19a5eaf09580e48014917a7fe43595.tar.gz
bcm5719-llvm-fb836f8c1a19a5eaf09580e48014917a7fe43595.zip
reinstate my patch: the miscompile was caused by an inverted branch in the
'and' case. llvm-svn: 121695
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index d7a6ea4655a..71d9ef84832 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1909,13 +1909,15 @@ static bool SimplifyBranchOnICmpChain(BranchInst *BI, const TargetData *TD) {
// then we evaluate them with an explicit branch first. Split the block
// right before the condbr to handle it.
if (ExtraCase) {
- return false;
-
BasicBlock *NewBB = BB->splitBasicBlock(BI, "switch.early.test");
// Remove the uncond branch added to the old block.
TerminatorInst *OldTI = BB->getTerminator();
- BranchInst::Create(EdgeBB, NewBB, ExtraCase, OldTI);
+ if (TrueWhenEqual)
+ BranchInst::Create(EdgeBB, NewBB, ExtraCase, OldTI);
+ else
+ BranchInst::Create(NewBB, EdgeBB, ExtraCase, OldTI);
+
OldTI->eraseFromParent();
// If there are PHI nodes in EdgeBB, then we need to add a new entry to them
@@ -1955,6 +1957,7 @@ static bool SimplifyBranchOnICmpChain(BranchInst *BI, const TargetData *TD) {
// Erase the old branch instruction.
EraseTerminatorInstAndDCECond(BI);
+
return true;
}
OpenPOWER on IntegriCloud