[llvm] [LV] Trim VFs that cause vector splitting when tail-folding with EVL (PR #222836)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 13 22:45:02 PDT 2026
https://github.com/ElvisWang123 commented:
> Ah right, so when we have two separate chains of types there might not be cast. In that case would it be sufficient then to also apply the same invalid cost for loads + stores if they need split?
>
> My main concern with the VPlan pass approach is that this a detail of the RISC-V VL optimizer leaking upwards. For example we're hard-coding the maximum number of registers as 8 before it needs split.
>
> I don't think returning an invalid cost is perfect either since that will also affect vectorcombine/slp costs. Maybe a better approach is to adjust the logic in `VFSelectionContext::getMaximizedVFForTarget` and use a new TTI hook to limit the maximum number of registers allowed for the widest type.
Relying on underlying values to determine this isn't quite accurate enough.
Take partial reductions, for instance:
```
%a = load i8 %ptr.0
%b = load i8 %ptr.1
%ext.a = zext i8 %a to i64
%ext.b = zext i8 %b to i64
%mul = mul %ext.a %ext.b
%red = add %red.phi, %mul
```
Early on, LV doesn't know if these operations will actually be folded into a partial reduction. If they are folded, the resulting wider type has fewer elements, and LV checks for splits based on i8. But if the fold is unsupported or unprofitable on the target, LV actually needs to account for i64.
Overall, I'd prefer to put the trimming pass after optimization pipeline to make this analysis more accurate.
https://github.com/llvm/llvm-project/pull/222836
More information about the llvm-commits
mailing list