[PATCH] D91398: [LoopVectorizer] Lower uniform loads as a single load (instead of relying on CSE)

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 14 12:17:37 PST 2020


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2667
+    if (!Operand || !OrigLoop->contains(Operand) ||
+        (Cost->isUniformAfterVectorization(Operand, State.VF)))
+      InputInstance.Lane = 0;
----------------
The VPRecplicateRecipe contains a `IsUniform` flag. I think it should be possible to pass the flag through from the recipe to `scalarizeInstruction`. Ideally the recipes should contain all information required for code-generation to avoid having to tie code generation directly to the cost-model.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5079
+    if (isa<LoadInst>(I) && Legal->isUniformMemOp(*I)) {
+      assert(WideningDecision == CM_Scalarize);
+      return true;
----------------
nit: message for assert.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:6272
                                                          ElementCount VF) {
+  assert(Legal->isUniformMemOp(*I));
+
----------------
nit: message for assert?


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:6451
 
-      if (Legal->isUniform(Ptr) &&
-          // Conditional loads and stores should be scalarized and predicated.
-          // isScalarWithPredication cannot be used here since masked
-          // gather/scatters are not considered scalar with predication.
-          !Legal->blockNeedsPredication(I.getParent())) {
+      if (Legal->isUniformMemOp(I)) {
         // TODO: Avoid replicating loads and stores instead of
----------------
this seems an unrelated refactoring, which could be split out and committed independently?


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

https://reviews.llvm.org/D91398



More information about the llvm-commits mailing list