[llvm-commits] [llvm] r126481 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/select-gep.ll

Benjamin Kramer benny.kra at googlemail.com
Fri Feb 25 02:33:33 PST 2011


Author: d0k
Date: Fri Feb 25 04:33:33 2011
New Revision: 126481

URL: http://llvm.org/viewvc/llvm-project?rev=126481&view=rev
Log:
Revert "SimplifyCFG: GEPs with just one non-constant index are also cheap."

Yes, there are other types than i8* and GEPs on them can produce an add+multiply.
We don't consider that cheap enough to be speculatively executed.

Modified:
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/trunk/test/Transforms/SimplifyCFG/select-gep.ll

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=126481&r1=126480&r2=126481&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Fri Feb 25 04:33:33 2011
@@ -247,13 +247,11 @@
     if (PBB->getFirstNonPHIOrDbg() != I)
       return false;
     break;
-  case Instruction::GetElementPtr: {
-    // GEPs are cheap if all indices are constant or if there's only one index.
-    GetElementPtrInst *GEP = cast<GetElementPtrInst>(I);
-    if (!GEP->hasAllConstantIndices() && GEP->getNumIndices() > 1)
+  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:

Modified: llvm/trunk/test/Transforms/SimplifyCFG/select-gep.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/select-gep.ll?rev=126481&r1=126480&r2=126481&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/select-gep.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/select-gep.ll Fri Feb 25 04:33:33 2011
@@ -15,7 +15,7 @@
   ret i8* %x.addr
 
 ; CHECK: @test1
-; CHECK: %x.addr = select i1 %cmp, i8* %incdec.ptr, i8* %x
+; CHECK-NOT: select
 ; CHECK: ret i8* %x.addr
 }
 





More information about the llvm-commits mailing list