[llvm] [VPlan] Handle live-in extend operands in partial reduction ::computeCost (PR #163175)
    Sander de Smalen via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Oct 23 01:10:11 PDT 2025
    
    
  
================
@@ -355,14 +360,15 @@ VPPartialReductionRecipe::computeCost(ElementCount VF,
     ExtAType = GetExtendKind(OpR);
   } else if (isa<VPReductionPHIRecipe>(OpR)) {
     auto RedPhiOp1R = getOperand(1)->getDefiningRecipe();
-    if (isa<VPWidenCastRecipe>(RedPhiOp1R)) {
+    if (isa_and_nonnull<VPWidenCastRecipe>(RedPhiOp1R)) {
----------------
sdesmalen-arm wrote:
I realise I should probably have been a bit clearer here; I don't believe that `OpR` (which is the chain operand) can ever be `nullptr`. In contrast, `getVecOp()` (==`getOperand(1)`) can be so that should be special cased here, but it may be clearer to write that as:
```
// The partial.reduce.add's vector operand might not be a live-in.
if (auto *RedPhiOp1R = getVecOp()->getDefiningRecipe()) {
  if (isa<VPWidenCastRecipe>(RedPhiOp1R) {
     ... 
  } else if (auto Widen = dyn_cast<VPWidenRecipe>(RedPhiOp1R))
     ...
}
```
https://github.com/llvm/llvm-project/pull/163175
    
    
More information about the llvm-commits
mailing list