[PATCH] D100273: [VectorCombine] Scalarize vector load/extract.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 11 14:22:15 PDT 2021


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/VectorCombine.cpp:784-804
+    auto *UI = dyn_cast<ExtractElementInst>(U);
+    if (!UI || UI->getParent() != LI->getParent())
+      return false;
+
+    // Check if any instruction between the load and the extract may modify
+    // memory.
+    if (LastCheckedInst->comesBefore(UI)) {
----------------
lebedev.ri wrote:
> Since we would be extracting from the original value,
> why do we care if it would have been overwritten sometimes later?
> Can't we just emit all loads right where the wide load was?
> 
> Can't we just emit all loads right where the wide load was?

We could, *if* the indices are all defined before the wide load. That's not the case in the cases I am most interested in.

At the moment the scalar loads are inserted at the point of the extracts, but if the index is defined before the wide load, we could create the narrow loads next to the widened loads. But that may be good as a follow up extensions?


================
Comment at: llvm/lib/Transforms/Vectorize/VectorCombine.cpp:806
+
+    auto *Index = dyn_cast<ConstantInt>(UI->getOperand(1));
+    OriginalCost +=
----------------
lebedev.ri wrote:
> Do we expect that all the CSE have happened by now?
> 
Most of it yes, but not for the code that the SLP vectorizer creates. We don't run dedicated CSE later either, just instcombine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100273



More information about the llvm-commits mailing list