]> git.ipfire.org Git - thirdparty/gcc.git/commit
vect: Allow reduc_index != 1 for COND_OPs.
authorRobin Dapp <rdapp@ventanamicro.com>
Tue, 21 Nov 2023 11:51:12 +0000 (12:51 +0100)
committerRobin Dapp <rdapp@ventanamicro.com>
Tue, 21 Nov 2023 20:06:13 +0000 (21:06 +0100)
commit2bbc7f4ef6329df62146fd6d0da5f30750cc72b4
tree5d230025f54ef3b66b2a30072f5f850a7d3e6fdb
parent638c2f3caf01b1b570b403235ad6a28bd8245fc6
vect: Allow reduc_index != 1 for COND_OPs.

In PR112406 Tamar found another problem with COND_OP reductions.
I wrongly assumed that the reduction variable will always remain in
operand 1, just as we create the COND_OP in ifcvt.  But of course,
addition being commutative, we are free to swap operand 1 and 2 and we
end up with e.g.

 _ifc__60 = .COND_ADD (_2, _6, MADPictureC1_lsm.10_25, MADPictureC1_lsm.10_25);

which does not pass the asserts I put in place.

This patch removes this restriction and allows the reduction index to be
2 as well.

gcc/ChangeLog:

PR middle-end/112406

* tree-vect-loop.cc (vectorize_fold_left_reduction): Allow
reduction index != 1.
(vect_transform_reduction): Handle reduction index != 1.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pr112406-2.c: New test.
gcc/testsuite/gcc.target/aarch64/pr112406-2.c [new file with mode: 0644]
gcc/tree-vect-loop.cc