[llvm] r200371 - LoopVectorizer: Don't count the induction variable multiple times

Arnold Schwaighofer aschwaighofer at apple.com
Tue Jan 28 20:36:12 PST 2014


Author: arnolds
Date: Tue Jan 28 22:36:12 2014
New Revision: 200371

URL: http://llvm.org/viewvc/llvm-project?rev=200371&view=rev
Log:
LoopVectorizer: Don't count the induction variable multiple times

When estimating register pressure, don't count the induction variable mulitple
times. It is unlikely to be unrolled. This is currently disabled and hidden
behind a flag ("enable-ind-var-reg-heur").

Modified:
    llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp

Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=200371&r1=200370&r2=200371&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Tue Jan 28 22:36:12 2014
@@ -188,6 +188,10 @@ static cl::opt<unsigned> NumberOfStoresT
     "vectorize-num-stores-pred", cl::init(0), cl::Hidden,
     cl::desc("Max number of stores to be predicated behind an if."));
 
+static cl::opt<bool> EnableIndVarRegisterHeur(
+    "enable-ind-var-reg-heur", cl::init(false), cl::Hidden,
+    cl::desc("Count the induction variable only once when unrolling"));
+
 static cl::opt<bool> EnableCondStoresVectorization(
     "enable-cond-stores-vec", cl::init(false), cl::Hidden,
     cl::desc("Enable if predication of stores during vectorization."));
@@ -5155,6 +5159,11 @@ LoopVectorizationCostModel::selectUnroll
   unsigned UF = PowerOf2Floor((TargetNumRegisters - R.LoopInvariantRegs) /
                               R.MaxLocalUsers);
 
+  // Don't count the induction variable as unrolled.
+  if (EnableIndVarRegisterHeur)
+    UF = PowerOf2Floor((TargetNumRegisters - R.LoopInvariantRegs - 1) /
+                       std::max(1U, (R.MaxLocalUsers - 1)));
+
   // Clamp the unroll factor ranges to reasonable factors.
   unsigned MaxUnrollSize = TTI.getMaximumUnrollFactor();
 





More information about the llvm-commits mailing list