[llvm] [InstCombine] Pull extract through broadcast (PR #143380)
    Nikita Popov via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Jun  9 12:27:33 PDT 2025
    
    
  
================
@@ -542,6 +542,13 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) {
         }
       }
     } else if (auto *SVI = dyn_cast<ShuffleVectorInst>(I)) {
+      // extractelt (shufflevector %v1, %v2, splat-mask) idx ->
+      // extractelt %v1, splat-mask[0]
+      auto Mask = SVI->getShuffleMask();
+      if (Mask[0] != PoisonMaskElem && all_equal(Mask))
----------------
nikic wrote:
Should also check `isa<PoisonValue>(SVI->getOperand(1))` to make sure the mask isn't a broadcast from the second operand. You won't be able to test this because it usually gets folded away earlier, but it can occur due to worklist order.
https://github.com/llvm/llvm-project/pull/143380
    
    
More information about the llvm-commits
mailing list