[llvm] [VPlan] Narrow VPWidenCastRecipe to scalar cast recipe. (PR #166514)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 4 02:53:29 PST 2026


================
@@ -1673,10 +1673,17 @@ static void narrowToSingleScalarRecipes(VPlan &Plan) {
           }))
         continue;
 
-      auto *Clone = new VPReplicateRecipe(
-          RepOrWidenR->getUnderlyingInstr(), RepOrWidenR->operands(),
-          true /*IsSingleScalar*/, nullptr, *RepOrWidenR);
-      Clone->insertBefore(RepOrWidenR);
+      VPSingleDefRecipe *Clone;
+      if (auto *CastR = dyn_cast<VPWidenCastRecipe>(RepOrWidenR)) {
+        Clone = VPBuilder(CastR).createScalarCast(
+            CastR->getOpcode(), CastR->getOperand(0), CastR->getResultType(),
+            CastR->getDebugLoc(), *CastR, *CastR);
----------------
Mel-Chen wrote:

Updated, set underlying value and new test llvm/test/Transforms/LoopVectorize/RISCV/narrowed-cast-cost.ll for this.

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


More information about the llvm-commits mailing list