]> git.ipfire.org Git - thirdparty/gcc.git/commit
VECT: Add decrement IV iteration loop control by variable amount support
authorJu-Zhe Zhong <juzhe.zhong@rivai.ai>
Thu, 25 May 2023 14:42:35 +0000 (22:42 +0800)
committerPan Li <pan2.li@intel.com>
Thu, 25 May 2023 14:48:22 +0000 (22:48 +0800)
commitf574e2dfae79055f16d0c63cc12df24815d8ead6
treee12b557836a13a5756eaf96052bfdfd119fc8f92
parent560bb845321f5ad039a318a081b0e88d9900f5cb
VECT: Add decrement IV iteration loop control by variable amount support

This patch is supporting decrement IV by following the flow designed by
Richard:

(1) In vect_set_loop_condition_partial_vectors, for the first iteration of:
    call vect_set_loop_controls_directly.

(2) vect_set_loop_controls_directly calculates "step" as in your patch.
If rgc has 1 control, this step is the SSA name created for that
control.  Otherwise the step is a fresh SSA name, as in your patch.

(3) vect_set_loop_controls_directly stores this step somewhere for later
use, probably in LOOP_VINFO.  Let's use "S" to refer to this stored
step.

(4) After the vect_set_loop_controls_directly call above, and outside
the "if" statement that now contains vect_set_loop_controls_directly,
check whether rgc->controls.length () > 1.  If so, use
vect_adjust_loop_lens_control to set the controls based on S.

Then the only caller of vect_adjust_loop_lens_control is
vect_set_loop_condition_partial_vectors.  And the starting
step for vect_adjust_loop_lens_control is always S.

This patch has well tested for single-rgroup and multiple-rgroup (SLP)
and passed all testcase in RISC-V port.

Signed-off-by: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
Co-Authored-By: Richard Sandiford <richard.sandiford@arm.com>
gcc/ChangeLog:

* tree-vect-loop-manip.cc (vect_adjust_loop_lens_control): New
function.
(vect_set_loop_controls_directly): Add decrement IV support.
(vect_set_loop_condition_partial_vectors): Ditto.
* tree-vect-loop.cc (_loop_vec_info::_loop_vec_info): New
variable.
* tree-vectorizer.h (LOOP_VINFO_USING_DECREMENTING_IV_P): New
macro.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-3.c: New test.
* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-4.c: New test.
* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-3.c: New test.
* gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-4.c: New test.
gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/multiple_rgroup-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/multiple_rgroup_run-4.c [new file with mode: 0644]
gcc/tree-vect-loop-manip.cc
gcc/tree-vect-loop.cc
gcc/tree-vectorizer.h