- Use O(1) check of basic block size limit.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 25 Jun 2008 07:50:12 +0000 (07:50 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 25 Jun 2008 07:50:12 +0000 (07:50 +0000)
- Avoid speculatively execute vector ops.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52703 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyCFG.cpp

index a993784cd25125f590e77531a200316016bc550f..c215b91259cf75236c4e9149b671c097dab93193 100644 (file)
@@ -965,8 +965,11 @@ HoistTerminator:
 static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *BB1) {
   // Only speculatively execution a single instruction (not counting the
   // terminator) for now.
-  if (BB1->size() != 2)
-    return false;
+  BasicBlock::iterator BBI = BB1->begin();
+  ++BBI; // must have at least a terminator
+  if (BBI == BB1->end()) return false; // only one inst
+  ++BBI;
+  if (BBI != BB1->end()) return false; // more than 2 insts.
 
   // Be conservative for now. FP select instruction can often be expensive.
   Value *BrCond = BI->getCondition();
@@ -1006,8 +1009,9 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *BB1) {
   case Instruction::Shl:
   case Instruction::LShr:
   case Instruction::AShr:
-    if (I->getOperand(0)->getType()->isFPOrFPVector())
-      return false;  // FP arithmetic might trap.
+    if (!I->getOperand(0)->getType()->isInteger())
+      // FP arithmetic might trap. Not worth doing for vector ops.
+      return false;
     break;   // These are all cheap and non-trapping instructions.
   }