[llvm] [LV] Bundle partial reductions inside VPExpressionRecipe (PR #147302)

Sam Tebbs via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 14 09:24:43 PDT 2025


================
@@ -350,19 +353,20 @@ VPPartialReductionRecipe::computeCost(ElementCount VF,
     }
   };
 
-  if (isa<VPWidenCastRecipe>(OpR)) {
+  if (isa_and_nonnull<VPWidenCastRecipe>(OpR)) {
     InputTypeA = Ctx.Types.inferScalarType(OpR->getOperand(0));
     ExtAType = GetExtendKind(OpR);
-  } else if (isa<VPReductionPHIRecipe>(OpR)) {
+  } else if (isa_and_nonnull<VPReductionPHIRecipe>(OpR)) {
     auto RedPhiOp1R = getOperand(1)->getDefiningRecipe();
-    if (isa<VPWidenCastRecipe>(RedPhiOp1R)) {
+    if (isa_and_nonnull<VPWidenCastRecipe>(RedPhiOp1R)) {
       InputTypeA = Ctx.Types.inferScalarType(RedPhiOp1R->getOperand(0));
       ExtAType = GetExtendKind(RedPhiOp1R);
-    } else if (auto Widen = dyn_cast<VPWidenRecipe>(RedPhiOp1R))
+    } else if (auto Widen = dyn_cast_if_present<VPWidenRecipe>(RedPhiOp1R))
       HandleWiden(Widen);
-  } else if (auto Widen = dyn_cast<VPWidenRecipe>(OpR)) {
+  } else if (auto Widen = dyn_cast_if_present<VPWidenRecipe>(OpR)) {
     HandleWiden(Widen);
-  } else if (auto Reduction = dyn_cast<VPPartialReductionRecipe>(OpR)) {
+  } else if (auto Reduction =
+                 dyn_cast_if_present<VPPartialReductionRecipe>(OpR)) {
----------------
SamTebbs33 wrote:

FYI these changes come from #163175

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


More information about the llvm-commits mailing list