[PATCH] D15177: [LoopVectorizer] Refine loop vectorizer's register usage calculator by ignoring specific instructions.
hfinkel@anl.gov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 10 02:46:36 PST 2015
hfinkel added inline comments.
================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:5634
@@ -5638,1 +5633,3 @@
+void LoopVectorizationCostModel::collectValuesToIgnore() {
+ // Ignore ephemeral values.
----------------
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.
================
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.
----------------
Aren't these also used by add or sub by a constant?
================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:5675
@@ +5674,3 @@
+ case Instruction::GetElementPtr: {
+ // Ignore GEP if its last operand is an inductoin variable so that it is
+ // a consecutive load/store and won't be vectorized as scatter/gather
----------------
Typo: inductoin
================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:5678
@@ +5677,3 @@
+ // pattern.
+ GetElementPtrInst *Gep = dyn_cast<GetElementPtrInst>(&Inst);
+ unsigned NumOperands = Gep->getNumOperands();
----------------
dyn_cast -> cast (it is known not to fail here)
================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:5680
@@ +5679,3 @@
+ unsigned NumOperands = Gep->getNumOperands();
+ if (Legal->isInductionVariable(Gep->getOperand(NumOperands - 1)))
+ ValuesToIgnore.insert(&Inst);
----------------
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.
http://reviews.llvm.org/D15177
More information about the llvm-commits
mailing list