[CodeGenPrepare] Exit earlier when optimizing selects (NFC)
authorVedant Kumar <vsk@apple.com>
Tue, 21 Aug 2018 23:42:23 +0000 (23:42 +0000)
committerVedant Kumar <vsk@apple.com>
Tue, 21 Aug 2018 23:42:23 +0000 (23:42 +0000)
When optimizing for size, this allows optimizeSelectInst to skip a
linear scan and exit early.

llvm-svn: 340367

llvm/lib/CodeGen/CodeGenPrepare.cpp

index 07167af..2478f95 100644 (file)
@@ -5592,6 +5592,10 @@ static Value *getTrueOrFalseValue(
 /// If we have a SelectInst that will likely profit from branch prediction,
 /// turn it into a branch.
 bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) {
+  // If branch conversion isn't desirable, exit early.
+  if (DisableSelectToBranch || OptSize || !TLI)
+    return false;
+
   // Find all consecutive select instructions that share the same condition.
   SmallVector<SelectInst *, 2> ASI;
   ASI.push_back(SI);
@@ -5613,8 +5617,7 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) {
   bool VectorCond = !SI->getCondition()->getType()->isIntegerTy(1);
 
   // Can we convert the 'select' to CF ?
-  if (DisableSelectToBranch || OptSize || !TLI || VectorCond ||
-      SI->getMetadata(LLVMContext::MD_unpredictable))
+  if (VectorCond || SI->getMetadata(LLVMContext::MD_unpredictable))
     return false;
 
   TargetLowering::SelectSupportKind SelectKind;