SimplifyCFG: GEPs with constant indices are cheap enough to be executed unconditionally.
[oota-llvm.git] / lib / Transforms / Utils / SimplifyCFG.cpp
index fb660dbfac100e899163128dc9138af2b1c61967..c6708857cb5601255cf26295524e527e004f8d4d 100644 (file)
@@ -247,6 +247,11 @@ static bool DominatesMergePoint(Value *V, BasicBlock *BB,
     if (PBB->getFirstNonPHIOrDbg() != I)
       return false;
     break;
+  case Instruction::GetElementPtr:
+    // GEPs are cheap if all indices are constant.
+    if (!cast<GetElementPtrInst>(I)->hasAllConstantIndices())
+      return false;
+    break;
   case Instruction::Add:
   case Instruction::Sub:
   case Instruction::And: