[PATCH] D71053: [LV] Take overhead of run-time checks into account during vectorization.

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 06:41:15 PST 2020


mkazantsev added a comment.

In the commit message:

  I see to possibilities to mitigate that.

to -> two

  bypass of vectorized loop and relay on the following optimizations to remove trivially dead code.

relay->rely?



================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:4963
+    // Tiny loops are handled in a special way.
+    if (ExpectedTC && *ExpectedTC < TinyTripCountVectorThreshold) {
+        if (EnableTinyLoopVectorization) {
----------------
I think that "forced" check should be done before this, and if it is forced, no further checks needed. With that, conrol flow within `if` branches should simplify a lot.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5040
+    LLVM_DEBUG(
+        dbgs() << "LV: Masked vectorization is not allowed. Continue with"
+                  "'normal' vectorization using epilogue\n");
----------------
nit: whitespace after "with" missing.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:6619
+static uint64_t getCostOfBlocks(LoopVectorizationCostModel &CM,
+                                Container &&C) {
+  uint64_t TotalCost = 0;
----------------
Maybe rename `C` -> `Blocks`?


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:6670
+
+  assert(CM.BestVF.Width != 0 && CM.BestVF.Width > 1 &&
+         "Best VF was not properly selected?");
----------------
Can be just `CM.BestVF.Width > 1`, the `!= 0` part will be simply implied.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:6692
+  if (RemainderTripCount == 0 && CM.requiresScalarEpilogue()) {
+    --VecTripCount;
+    RemainderTripCount = CM.BestVF.Width;
----------------
Assert that it was at least 1 before it?


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:6717
+
+    assert(isa<BranchInst>(ILV.LoopBypassBlocks.front()->getTerminator()) &&
+           "RT check should end with branch instruction.");
----------------
Also assert that it is conditional? This fact seems to be used below on line 6766.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71053/new/

https://reviews.llvm.org/D71053





More information about the llvm-commits mailing list