[llvm] [LV] Support tail-folded epilogue loops (PR #208764)
Hassnaa Hamdi via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 04:54:16 PDT 2026
================
@@ -45,20 +45,44 @@ void VPlanTransforms::replaceWideCanonicalIVWithWideIV(
if (!LoopRegion)
return;
- auto *WideCanIV =
- findUserOf<VPWidenCanonicalIVRecipe>(LoopRegion->getCanonicalIV());
+ VPWidenCanonicalIVRecipe *WideCanIV = nullptr;
+ VPIRValue *StartValue = nullptr;
+ // VPWidenCanonicalIVRecipe is either a direct user of CanonicalIV or
+ // Add (CanonicalIV, resumeValue) (like the case for tail-folded epilogue).
+ for (auto *User : LoopRegion->getCanonicalIV()->users()) {
+ if (isa<VPWidenCanonicalIVRecipe>(User)) {
+ WideCanIV = cast<VPWidenCanonicalIVRecipe>(User);
+ StartValue = Plan.getZero(WideCanIV->getScalarType());
+ break;
+ }
+ if (isa<VPInstruction>(User)) {
+ auto *UserInstr = cast<VPInstruction>(User);
+ auto *It = find_if(UserInstr->users(), IsaPred<VPWidenCanonicalIVRecipe>);
+ if (It != UserInstr->user_end()) {
+ WideCanIV = cast<VPWidenCanonicalIVRecipe>(*It);
----------------
hassnaaHamdi wrote:
I think this statement: `find_if(UserInstr->users(), IsaPred<VPWidenCanonicalIVRecipe>);` already does that. It iterates over all the users of `User/UserInstr` to find if it's the Recipe.
Is that what you mean? or do you mean the Recipe could be **indirect** user of `User/UserInstr` ?
https://github.com/llvm/llvm-project/pull/208764
More information about the llvm-commits
mailing list