[PATCH] D21048: [LV] Enable vectorization of loops where the IV has an external use

Ayal Zaks via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 15:26:53 PDT 2016

Ayal added a subscriber: Ayal.
Ayal added a comment.

An alternative which I'm sure you thought of would be to fix/clean up such external users of IV's as a preparatory step (SimplifyIndVar?), eliminating them from the loop before starting to vectorize it. This may be a good thing to do early, for other "uses".

It may be somewhat more efficient to traverse the LCSSA phi's at the single exit block that are fed by allowed-to-exit IV's in order to fix/clean them up, instead of traversing mostly irrelevant internal uses in search for out-of-loop ones.

Comment at: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp:3299-3300
@@ +3298,4 @@
+  // An external user of the penultimate value need to see EndValue - Step.
+  // The simplest way to get this is to recompute it from the constituent SCEVs,
+  // that is Start + (Step * (CRD - 1)).
+  for (User *U : OrigPhi->users()) {

"simplest" as it employs II.transform, which takes care of pointers as well; one could argue that doing EndValue - Step is simpler..



More information about the llvm-commits mailing list