[PATCH] D29900: [SLP] Fix for PR31879: vectorize repeated scalar ops that don't get put back into a vector

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 12:05:23 PST 2017


ABataev added inline comments.


================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:1629
+/// Checks that \p I is used in the single instruction.
+static bool hasOneUse(Instruction *I) {
+  if (I->hasOneUse())
----------------
hfinkel wrote:
> Maybe this should be called hasOneUser?
Ok, will do.


================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:1672
           Instruction *E = cast<Instruction>(VL[i]);
-          if (E->hasOneUse())
+          if (hasOneUse(E))
             // Take credit for instruction that will become dead.
----------------
hfinkel wrote:
> Why are we checking this use(r) count at all? If canReuseExtract is true, then don't we just care that all users are part of the to-be-vectorized tree?
> 
It does not check if we can vectorize extract, it checks should we remove this extract from the code or there are other users of this extract. If we can remove this extract from the code, we can consider this instruction as dead and subtract from the cost, otherwise this instruction is alive and its cost should be considered during vectorization.


https://reviews.llvm.org/D29900





More information about the llvm-commits mailing list