[PATCH] D101726: [LV] Account for tripcount when calculation vectorization profitability

Bardia Mahjour via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 3 14:52:30 PDT 2021


bmahjour added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5894
+    // If we are folding the tail and the trip count is a known (possibly small)
+    // constant, account for that by rounding the count up to the number of
+    // known iterations.
----------------
but the count is the scalar trip count while the width is the vectorization factor....it seems odd that this calculation combines the two concepts together. Also if the trip count is a large constant, wouldn't the ceiling cause the VF to be effectively ignored?

Perhaps you can achieve the desired outcome by adjusting the cost elsewhere (say in `expectedCost`) and preferably with a target hook.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5898
+    uint64_t RTCostB = CostB * ceil(MaxTripCount, B.Width.getKnownMinValue());
+    return RTCostA < RTCostB;
+  }
----------------
For this inequality to compare the per-lane costs, CostA above should be multiplied by ceil(...,B.Width) and CostB should be multiplied by ceil(...,A.Width).


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

https://reviews.llvm.org/D101726



More information about the llvm-commits mailing list