[PATCH] D15177: [LoopVectorizer] Refine loop vectorizer's register usage calculator by ignoring specific instructions.

Cong Hou via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 11 15:35:39 PST 2015


congh added inline comments.

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:5634
@@ -5638,1 +5633,3 @@
 
+void LoopVectorizationCostModel::collectValuesToIgnore() {
+  // Ignore ephemeral values.
----------------
hfinkel wrote:
> You need to have a different behavior here for VF == 1 vs. VF > 1. The VF == 1 case is important because it is used to control the interleave factor (calculateRegisterUsage is called from LoopVectorizationCostModel::selectInterleaveCount). For the VF == 1 case, a number of these exclusions don't apply.
Good catch! I have created a new set to store values to ignore when VF > 1 and only add my newly added values to ignore to this new set. This set is then used to calculate register usages for VF > 1.

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:5647
@@ +5646,3 @@
+  // Ignore induction phis that are only used in either GetElementPtr or ICmp
+  // instruction to exit loop. Induction variables usually have large types and
+  // can have big impact when estimating register usage.
----------------
hfinkel wrote:
> Aren't these also used by add or sub by a constant?
Yes, induction variables can participate in arithmetic operations. But I still have to follow the def-use chain and check if the value that is defined directly/indirectly is stored (it seems that the reduction with an induction variable cannot be vectorized now). Do you have any idea except doing it in a DFS manner?

================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:5680
@@ +5679,3 @@
+        unsigned NumOperands = Gep->getNumOperands();
+        if (Legal->isInductionVariable(Gep->getOperand(NumOperands - 1)))
+          ValuesToIgnore.insert(&Inst);
----------------
hfinkel wrote:
> I suspect you want to use getGEPInductionOperand (from include/llvm/Analysis/VectorUtils.h) to pick the operand index so that you ignore trailing zero operands.
I think getGEPInductionOperand is what I want here. I have updated this part. Thanks!


http://reviews.llvm.org/D15177





More information about the llvm-commits mailing list