llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[SLP]Add support for forest (multitree) single register vectorization instead of wide vectors

Open alexey-bataev opened this issue 6 months ago • 3 comments

Instead of wide vectors, we'd better to support forest (multitree) vectorization. This later can be required to improve vectorization of multiused scalars.

alexey-bataev avatar May 19 '26 13:05 alexey-bataev

@alexey-bataev @bababuck @hazzlim

I'd like to help with forest vectorization, and I'm proposing a split so we don't duplicate work.

#237603 adds small AArch64 tests to multiple_reduction.ll for adjacent reductions over the same loads (#55350):

@mutual_v4i32: neither reduction is vectorized, although each one vectorizes on its own (the *_only_v4i32 controls). @mutual_v16i32: one reduction becomes a single <16 x i32> vector and the other stays scalar, fed by extracts. These could serve as the target for the reduction part of this work.

Proposed split:

Multi-tree groundwork (#222805, Ryan). I'm happy to review it, and to help split it into smaller NFC patches if that makes it easier to keep up to date with main.

Reductions (me). Following Alexey's suggestion to start with reductions: first, build register-sized trees instead of long vectors in tryToReduce; then, cost adjacent reductions together, so that scalars used by another tree in the same forest are not charged extracts.

Store chains (#171917, Ryan), once the groundwork is in.

@hazzlim, which part would you like to take, if any?

madhur13490 avatar Oct 31 '26 18:10 madhur13490

Thanks @madhur13490 for the outline! This sounds good to me. #222805 is waiting for both #229653 and #229846. Once those get merged I'll rebase #222805 and we can get that moved along. I have some work done for the reductions though it's very rough and probably out of date so I don't think it's worth much anymore- that is it sounds good if you want to take on the reduction case once the groundwork is merged, I can help with reviews!

bababuck avatar Nov 02 '26 02:11 bababuck

Yes thanks @madhur13490 - I'm keen to help in any way I can, perhaps even if it is just with reviews initially given that the initial things are mostly covered by you both.

One of our broader goals is to extend things to cover producer-consumer vectorization across sibling loops, as in https://github.com/llvm/llvm-project/pull/216013

hazzlim avatar Nov 02 '26 10:11 hazzlim