[PATCH] D147562: [SLP] Add TreeEntry into PostponedGathers if it depends on another previously postponed TreeEntry.

Ivan Kelarev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 4 12:38:44 PDT 2023


ikelarev created this revision.
ikelarev added reviewers: ABataev, vdmitrie.
Herald added subscribers: vporpo, hiraditya.
Herald added a project: All.
ikelarev requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

https://reviews.llvm.org/D144958 change introduced PostponedGathers into SLP Vectorizer. As far as I understand it allows to generate temporary fake loads instead of real instructions and update later postponed entries at the end of vectorization. But during this update can be generated an instruction which uses a fake load which was already replaced. That leads to an incorrect dependency and assertion "trying to erase instruction with users" failure in BoUpSLP destructor.

This change helps to avoid such a scenario by adding into PostponedGathers every node which depends on the node already added into PostponedGathers.


https://reviews.llvm.org/D147562

Files:
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp


Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11515,6 +11515,9 @@
         // process to keep correct order.
         return Delayed;
       }
+      if (any_of(Entries,
+                 [&](const TreeEntry *E) { return PostponedGathers.count(E); }))
+        PostponedGathers.insert(E);
       assert((Entries.size() == 1 || Entries.size() == 2) &&
              "Expected shuffle of 1 or 2 entries.");
       if (!Resized) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147562.510894.patch
Type: text/x-patch
Size: 613 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230404/84e847cf/attachment.bin>


More information about the llvm-commits mailing list