[llvm] [VPlan] Replace PhiR operand of ComputeRdxResult with VPIRFlags. (PR #174026)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 4 04:59:30 PST 2026
================
@@ -7305,8 +7305,20 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
EpiRedResult->getOpcode() != VPInstruction::ComputeFindIVResult))
return;
- auto *EpiRedHeaderPhi =
- cast<VPReductionPHIRecipe>(EpiRedResult->getOperand(0));
+ VPReductionPHIRecipe *EpiRedHeaderPhi;
+ if (EpiRedResult->getOpcode() == VPInstruction::ComputeReductionResult) {
+ // Find the reduction phi by looking at the other user of operand 0.
+ VPValue *Op = EpiRedResult->getOperand(0);
+ auto *OtherUser = *find_if(
+ Op->users(), [EpiRedResult](VPUser *U) { return U != EpiRedResult; });
+ if (auto *Phi = dyn_cast<VPReductionPHIRecipe>(OtherUser))
+ EpiRedHeaderPhi = Phi;
+ else // For truncated reductions, look through the cast.
----------------
ayalz wrote:
nit: can fold into the declaration of EpiRedHeaderPhi above:
```
VPReductionPHIRecipe *EpiRedHeaderPhi = dyn_cast<VPReductionPHIRecipe>(OtherUser));
```
or into
```
if (!EpiRedHeaderPhi = dyn_cast<VPReductionPHIRecipe>(OtherUser))
```
https://github.com/llvm/llvm-project/pull/174026
More information about the llvm-commits
mailing list