[llvm] r340367 - [CodeGenPrepare] Exit earlier when optimizing selects (NFC)

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 21 16:42:23 PDT 2018


Author: vedantk
Date: Tue Aug 21 16:42:23 2018
New Revision: 340367

URL: http://llvm.org/viewvc/llvm-project?rev=340367&view=rev
Log:
[CodeGenPrepare] Exit earlier when optimizing selects (NFC)

When optimizing for size, this allows optimizeSelectInst to skip a
linear scan and exit early.

Modified:
    llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp

Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=340367&r1=340366&r2=340367&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Tue Aug 21 16:42:23 2018
@@ -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(
   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;




More information about the llvm-commits mailing list