[PATCH] D32729: LV: Don't vectorize with unknown loop counts on divergent targets

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 13:46:15 PDT 2017


Ayal added inline comments.


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:6322
 
   unsigned MaxVF = computeFeasibleMaxVF(OptForSize);
+  if (OptForSize && TC % MaxVF != 0) {
----------------
Here we should indeed continue to use `(OptForSize)` only, rather than `(OptForSize || OptForDivergent)`, right?


================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:6323
   unsigned MaxVF = computeFeasibleMaxVF(OptForSize);
-
-  if (TC % MaxVF != 0) {
+  if (OptForSize && TC % MaxVF != 0) {
     // If the trip count that we found modulo the vectorization factor is not
----------------
Should this also be `if ((OptForSize || OptForDivergent) && TC % MaxVF != 0)` ?

It may be better to have one `AvoidTailLoop` flag, which is set if we're either really optimizing for size, or deal with a tiny loop, or optimize for a divergent target. Check here if a tail is needed for whatever reason, with a debug dump stating simply that a tail is required when it must be avoided. The reason why a tail must be avoided can be dumped separately when setting `AvoidTailLoop`. Not sure how to best handle the different `ORE` reports though; perhaps by refactoring out an `isTailLoopNeeded()`?


https://reviews.llvm.org/D32729





More information about the llvm-commits mailing list