[llvm] [VPlan] Embed widening decisions in recipes (NFCI) (PR #195385)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun May 3 14:07:12 PDT 2026


https://github.com/fhahn commented:

For the transition towards folding various recipes into VPInstruction & co to reduce unnecessary duplication, we need a way to express the widening decision directly inside VPInstruction, which currently is the main recipe that does not directly imply a widening decisions. There are a few others that produce a single-scalar/scalar-for-all lanes like ScalarIVSteps, but VPInstruction is the main outlier, handling all three widening options somewhat implicitly.

 It would be good to start focusing on VPInstruction and trying to subsume obvious duplicated recipes. We should be able to get there incrementally, by starting with tracking the widening decision in VPInstruction. Existing https://github.com/llvm/llvm-project/pull/129712 and https://github.com/llvm/llvm-project/pull/141429 could serve as starting point, by tracking single-scalar first.

This could then be easily extended to encode the full range with an enum as proposed here, coupled with moving cases from VPReplicateRecipe over to VPInstruction. 

I think it would still be good to tie the widening decision immutably to a recipe instance (somewhat fixing the current outlier VPInstruction). Almost all current recipes already encode this, so I am not sure we should add a field to track the state that is already explicit for most recipes as first step. 

At least initially, I think it would also be good to keep the distinction between the widening encoded in a recipe, and changes done via analysis + transform (e.g. if we can determine that a recipe producing a vector is only used as scalar, we should convert it to a single-scalar recipe)

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


More information about the llvm-commits mailing list