[llvm] [VPlan] Introduce vputils::getSingleScalarClone (PR #161667)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 21 06:52:00 PDT 2025


================
@@ -1309,15 +1296,14 @@ static void narrowToSingleScalarRecipes(VPlan &Plan) {
       auto *RepOrWidenR = cast<VPSingleDefRecipe>(&R);
       if (RepR && isa<StoreInst>(RepR->getUnderlyingInstr()) &&
           vputils::isSingleScalar(RepR->getOperand(1))) {
-        auto *Clone = new VPReplicateRecipe(
-            RepOrWidenR->getUnderlyingInstr(), RepOrWidenR->operands(),
-            true /*IsSingleScalar*/, nullptr /*Mask*/, *RepR /*Metadata*/);
+        auto *Clone =
+            cast<VPReplicateRecipe>(vputils::getSingleScalarClone(RepOrWidenR));
         Clone->insertBefore(RepOrWidenR);
         auto *Ext = new VPInstruction(VPInstruction::ExtractLastElement,
                                       {Clone->getOperand(0)});
         Ext->insertBefore(Clone);
         Clone->setOperand(0, Ext);
-        RepR->eraseFromParent();
+        RepOrWidenR->eraseFromParent();
----------------
david-arm wrote:

nit: unrelated change.

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


More information about the llvm-commits mailing list