[llvm] [LV][VPlan] Add initial support for CSA vectorization (PR #121222)
Michael Maitland via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 06:20:04 PST 2025
michaelmaitland wrote:
@ayalz thanks for the review!
> Continuing with this argument, better to also sink the loading of a[i] to after the loop, instead of loading vectorized va with mask inside the loop?
I agree in the example you bring up in your example. But consider a case where a[i] is needed unconditionally in the loop. For example if `cond[i]` is replaced with `a[i]`. Then doing it after the loop is doing duplicate loads. Additionally, consider that `t = f(a, b, c)`, then we need to keep track of `a, b, c` live out of the loop, which may be tricky.
I think there is some room to do such an optimization, but I prefer to leave this as future work.
> The reduction becomes a "FindLast" reduction once this function is sunk. Sound reasonable?
According to https://github.com/llvm/llvm-project/pull/106560#issuecomment-2419166743, there is no plan to support `FindLast` at the moment. Above I describe a scenario where it is not beneficial to do this sinking, so we would not be able to rely on `FindLast` in all instances.
> Finally, note that LV already supports some sort of "CSA", introduced by @annamthomas some years ago in https://reviews.llvm.org/D52656; see test variant_val_store_to_inv_address_conditional in llvm/test/Transforms/LoopVectorize/X86/invariant-store-vectorization.ll - a conditional store to the same address could be converted into a conditional scalar assignment coupled with sinking the conditional store to after the loop.
This sounds like a good idea for future improvement of these loops.
https://github.com/llvm/llvm-project/pull/121222
More information about the llvm-commits
mailing list