[llvm] b7e38ff - [InstCombine] Add old extract to worklist for DCE

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 5 08:00:48 PDT 2023


Author: Nikita Popov
Date: 2023-07-05T17:00:40+02:00
New Revision: b7e38ff22326d7bcbd01f080dc91f47be25e703e

URL: https://github.com/llvm/llvm-project/commit/b7e38ff22326d7bcbd01f080dc91f47be25e703e
DIFF: https://github.com/llvm/llvm-project/commit/b7e38ff22326d7bcbd01f080dc91f47be25e703e.diff

LOG: [InstCombine] Add old extract to worklist for DCE

To make sure it is removed in the same InstCombine iteration.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index c969ad8ed37cf7..ae18e2c3fe5136 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -171,8 +171,11 @@ Instruction *InstCombinerImpl::scalarizePHI(ExtractElementInst &EI,
     }
   }
 
-  for (auto *E : Extracts)
+  for (auto *E : Extracts) {
     replaceInstUsesWith(*E, scalarPHI);
+    // Add old extract to worklist for DCE.
+    addToWorklist(E);
+  }
 
   return &EI;
 }


        


More information about the llvm-commits mailing list