[llvm] [InstCombine] Pull extract through broadcast (PR #143380)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 9 07:22:10 PDT 2025


================
@@ -542,6 +542,12 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) {
         }
       }
     } else if (auto *SVI = dyn_cast<ShuffleVectorInst>(I)) {
+      // extractelt (shufflevector %v1, %v2, zeroinitializer) ->
+      // extractelt %v1, 0
+      if (isa<FixedVectorType>(SVI->getType()))
+        if (all_of(SVI->getShuffleMask(), [](int Elt) { return Elt == 0; }))
----------------
RKSimon wrote:

This is probably worthwhile for any splat shuffle mask (assuming no undef mask elts)

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


More information about the llvm-commits mailing list