[llvm] r205346 - Use TopTTI->getGEPCost from within getUserCost

Hal Finkel hfinkel at anl.gov
Tue Apr 1 11:50:06 PDT 2014


Author: hfinkel
Date: Tue Apr  1 13:50:06 2014
New Revision: 205346

URL: http://llvm.org/viewvc/llvm-project?rev=205346&view=rev
Log:
Use TopTTI->getGEPCost from within getUserCost

The implementation of getUserCost had duplicated (and hard-coded) the default
logic in getGEPCost. Instead, it is better to use getGEPCost directly, which
limits the default logic to the implementation of one function, and allows
targets to override the behavior.

No functionality change intended.

Modified:
    llvm/trunk/lib/Analysis/TargetTransformInfo.cpp

Modified: llvm/trunk/lib/Analysis/TargetTransformInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetTransformInfo.cpp?rev=205346&r1=205345&r2=205346&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/TargetTransformInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/TargetTransformInfo.cpp Tue Apr  1 13:50:06 2014
@@ -415,10 +415,10 @@ struct NoTTI final : ImmutablePass, Targ
     if (isa<PHINode>(U))
       return TCC_Free; // Model all PHI nodes as free.
 
-    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U))
-      // In the basic model we just assume that all-constant GEPs will be
-      // folded into their uses via addressing modes.
-      return GEP->hasAllConstantIndices() ? TCC_Free : TCC_Basic;
+    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
+      SmallVector<const Value *, 4> Indices(GEP->idx_begin(), GEP->idx_end());
+      return TopTTI->getGEPCost(GEP->getPointerOperand(), Indices);
+    }
 
     if (ImmutableCallSite CS = U) {
       const Function *F = CS.getCalledFunction();





More information about the llvm-commits mailing list