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

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 02:45:29 PDT 2024


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

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

>From 79372b10c475a488e5546185b0bf556ab8a24bde Mon Sep 17 00:00:00 2001
From: tcwzxx <tcwzxx at gmail.com>
Date: Fri, 30 Aug 2024 17:22:51 +0800
Subject: [PATCH] Remove useless code

---
 .../Transforms/Vectorize/SLPVectorizer.cpp    | 19 -------------------
 1 file changed, 19 deletions(-)

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.");



More information about the llvm-commits mailing list