[llvm-commits] [llvm] r52224 - /llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Evan Cheng evan.cheng at apple.com
Wed Jun 11 12:18:20 PDT 2008


Author: evancheng
Date: Wed Jun 11 14:18:20 2008
New Revision: 52224

URL: http://llvm.org/viewvc/llvm-project?rev=52224&view=rev
Log:
For now, avoid generating FP select instructions in order to speculatively execute integer arithmetic instructions. FP selects are more likely to be expensive (even compared to branch on fcmp). This is not a wonderful solution but I rather err on the side of conservative.

This fixes the heapsort performance regressions.

Modified:
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=52224&r1=52223&r2=52224&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Jun 11 14:18:20 2008
@@ -965,6 +965,12 @@
   if (BB1->size() != 2)
     return false;
 
+  // Be conservative for now. FP select instruction can often be expensive.
+  Value *BrCond = BI->getCondition();
+  if (isa<Instruction>(BrCond) &&
+      cast<Instruction>(BrCond)->getOpcode() == Instruction::FCmp)
+    return false;
+
   // If BB1 is actually on the false edge of the conditional branch, remember
   // to swap the select operands later.
   bool Invert = false;
@@ -1029,8 +1035,7 @@
   BasicBlock::iterator InsertPos = BI;
   if (InsertPos != BIParent->begin())
     --InsertPos;
-  if (InsertPos->getOpcode() == Instruction::ICmp ||
-      InsertPos->getOpcode() == Instruction::FCmp)
+  if (InsertPos == BrCond)
     BIParent->getInstList().splice(InsertPos, BB1->getInstList(), I);
   else
     BIParent->getInstList().splice(BI, BB1->getInstList(), I);
@@ -1039,10 +1044,10 @@
   // false value is the previously determined FalseV.
   SelectInst *SI;
   if (Invert)
-    SI = SelectInst::Create(BI->getCondition(), FalseV, I,
+    SI = SelectInst::Create(BrCond, FalseV, I,
                             FalseV->getName() + "." + I->getName(), BI);
   else
-    SI = SelectInst::Create(BI->getCondition(), I, FalseV,
+    SI = SelectInst::Create(BrCond, I, FalseV,
                             I->getName() + "." + FalseV->getName(), BI);
 
   // Make the PHI node use the select for all incoming values for "then" and





More information about the llvm-commits mailing list