[PATCH] D37425: LoopVectorize: MaxVF should not be larger than the loop trip count

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 4 02:45:04 PDT 2017


Ayal added inline comments.


================
Comment at: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp:6165
   if (!OptForSize) // Remaining checks deal with scalar loop when OptForSize.
     return computeFeasibleMaxVF(OptForSize);
 
----------------
Would be good to restrict MaxVF to TC even if we're not OptForSize, although it's probably less likely to have a known TC that is larger than Tiny but smaller than current MaxVF.


================
Comment at: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp:6243
+  } else if (ConstTripCount && ConstTripCount < MaxVectorSize &&
+             isPowerOf2_32(ConstTripCount))
+    MaxVectorSize = ConstTripCount;
----------------
Better set MaxVectorSize to PowerOf2Floor(ConstTripCount), to also handle the case where ConstTripCount is not a power of 2.

Also, while we're at it: `computeFeasibleMaxVF()` is currently not required/documented to return a power of 2. We should either check that MaxVF is a power of 2 when checking `if (TC % MaxVF != 0)`, and then can simply set MaxVectorSize to ConstTripCount here. Otherwise we should document/assert that MaxVF is a power of 2.


Repository:
  rL LLVM

https://reviews.llvm.org/D37425





More information about the llvm-commits mailing list