[PATCH] D32446: [SimplifyCFG] Use getSingleSuccessor() to simplify some code
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 11:14:54 PDT 2017
craig.topper created this revision.
Rather than acquiring the TerminatorInst and asking how many successors it has and comparing to 1 this patch just uses getSingleSuccessor() which should be equivalent.
https://reviews.llvm.org/D32446
Files:
lib/Transforms/Utils/SimplifyCFG.cpp
Index: lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- lib/Transforms/Utils/SimplifyCFG.cpp
+++ lib/Transforms/Utils/SimplifyCFG.cpp
@@ -5835,18 +5835,14 @@
} else {
// If Successor #1 has multiple preds, we may be able to conditionally
// execute Successor #0 if it branches to Successor #1.
- TerminatorInst *Succ0TI = BI->getSuccessor(0)->getTerminator();
- if (Succ0TI->getNumSuccessors() == 1 &&
- Succ0TI->getSuccessor(0) == BI->getSuccessor(1))
+ if (BI->getSuccessor(0)->getSingleSuccessor() == BI->getSuccessor(1))
if (SpeculativelyExecuteBB(BI, BI->getSuccessor(0), TTI))
return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
}
} else if (BI->getSuccessor(1)->getSinglePredecessor()) {
// If Successor #0 has multiple preds, we may be able to conditionally
// execute Successor #1 if it branches to Successor #0.
- TerminatorInst *Succ1TI = BI->getSuccessor(1)->getTerminator();
- if (Succ1TI->getNumSuccessors() == 1 &&
- Succ1TI->getSuccessor(0) == BI->getSuccessor(0))
+ if (BI->getSuccessor(1)->getSingleSuccessor() == BI->getSuccessor(0))
if (SpeculativelyExecuteBB(BI, BI->getSuccessor(1), TTI))
return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32446.96431.patch
Type: text/x-patch
Size: 1357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170424/979655b2/attachment.bin>
More information about the llvm-commits
mailing list