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

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 5 03:44:29 PST 2025


================
@@ -208,19 +208,7 @@ static bool sinkScalarOperands(VPlan &Plan) {
     if (NeedsDuplicating) {
       if (ScalarVFOnly)
         continue;
-      VPSingleDefRecipe *Clone;
-      if (auto *SinkCandidateRepR =
-              dyn_cast<VPReplicateRecipe>(SinkCandidate)) {
-        // TODO: Handle converting to uniform recipes as separate transform,
-        // then cloning should be sufficient here.
-        Instruction *I = SinkCandidate->getUnderlyingInstr();
-        Clone = new VPReplicateRecipe(I, SinkCandidate->operands(), true,
-                                      nullptr /*Mask*/, *SinkCandidateRepR);
-        // TODO: add ".cloned" suffix to name of Clone's VPValue.
-      } else {
-        Clone = SinkCandidate->clone();
-      }
-
+      VPSingleDefRecipe *Clone = vputils::getSingleScalarClone(SinkCandidate);
----------------
artagnon wrote:

Okay, I've concluded that this is a very particular case that cannot be narrowed independently. I can't explain why very well, but you can look at the test diff after replacing this with a plain clone.

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


More information about the llvm-commits mailing list