[llvm] [LV] Add initial support for vectorizing literal struct return values (PR #109833)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 4 10:51:50 PST 2024
fhahn wrote:
> I've looked at the multiple result `VPWidenCallRecipe` approach in #112402 (prototype patch). I've got it working for `VPWidenCallRecipe` (no replication yet), but I'm unsure of the approach. It seems to require more refactoring and special cases than allowing widened struct values. The initial problems are:
>
> * `VPRecipeWithIRFlags` currently forces the recipe to inherit from `VPSingleDefRecipe`
>
> * I removed this restriction in [dbedb67](https://github.com/llvm/llvm-project/commit/dbedb67e957574100b7a368526a064299cbf14ed) (a moderately sized refactor)
This seems reasonable in general, although would be good if possible to avoid too many changes, possibly by keeping `VPRecipeIRFlags` as single def for now, moving the IR flags to a separate class with `VPRecipeIRFlags` inheriting from both `VPSingleDefRecipe` & the class to manage the flags?
> * Note: Struct return calls can have FMFs since [[IR] Allow fast math flags on calls with homogeneous FP struct types #110506](https://github.com/llvm/llvm-project/pull/110506)
> * `VPRecipeBuilder` assumes a 1-to-1 mapping from `Instruction` to (single-def) recipe
>
> * ~Currently worked around by special-casing `extractvalue`: https://github.com/llvm/llvm-project/blob/2aaf07c4fb69d21ded3109f5cb408196064b5f0e/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h#L185-L194
> ~
That seems fine to start with to me. We intentionally avoided breaking this mapping and complicating the builder.
> * Attempted to improve this by allowing `RecipeBuilder` to map (LLVM) instructions to VPValues in [cd73ad1](https://github.com/llvm/llvm-project/commit/cd73ad1da345cefe92a267ef6a247ce16552dd33)
> * `extractvalue` is also special-cased in `tryToBuildVPlanWithVPRecipes()` (as it does not directly produce a recipe)
>
> There may be a few issues to solve around replication too (but I've not got there yet).
>
> Just posting my initial thoughts in case I've missed something as I'm still fairly new to looking at `VPlan` 🙂
Would it be possible to get an initial version working without support for replicate recipes?
https://github.com/llvm/llvm-project/pull/109833
More information about the llvm-commits
mailing list