[llvm] [SLP][NFC] Remove useless code of deleting ExtractElementInst (PR #106697)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 02:46:04 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: tcwzxx (tcwzxx)

<details>
<summary>Changes</summary>

`removeInstructionsAndOperands` is already able to correctly delete `ExtractElementInst`.
Hope no missed any case.

---
Full diff: https://github.com/llvm/llvm-project/pull/106697.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (-19) 


``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index fe57dbfc93d3e7..5129cf85b4773a 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -12178,25 +12178,6 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
         VecBase = TE->VectorizedValue;
       assert(VecBase && "Expected vectorized value.");
       UniqueBases.insert(VecBase);
-      // If the only one use is vectorized - can delete the extractelement
-      // itself.
-      if (!EI->hasOneUse() || (NumParts != 1 && count(E->Scalars, EI) > 1) ||
-          any_of(EI->users(), [&](User *U) {
-            const TreeEntry *UTE = R.getTreeEntry(U);
-            return !UTE || R.MultiNodeScalars.contains(U) ||
-                   (isa<GetElementPtrInst>(U) &&
-                    !R.areAllUsersVectorized(cast<Instruction>(U))) ||
-                   count_if(R.VectorizableTree,
-                            [&](const std::unique_ptr<TreeEntry> &TE) {
-                              return any_of(TE->UserTreeIndices,
-                                            [&](const EdgeInfo &Edge) {
-                                              return Edge.UserTE == UTE;
-                                            }) &&
-                                     is_contained(TE->Scalars, EI);
-                            }) != 1;
-          }))
-        continue;
-      R.eraseInstruction(EI);
     }
     if (NumParts == 1 || UniqueBases.size() == 1) {
       assert(VecBase && "Expected vectorized value.");

``````````

</details>


https://github.com/llvm/llvm-project/pull/106697


More information about the llvm-commits mailing list