Skip to content
Snippets Groups Projects
Commit 4a0a8dc1 authored by Juzhe-Zhong's avatar Juzhe-Zhong Committed by Pan Li
Browse files

RISC-V: Fix bug of earliest fusion for infinite loop[VSETVL PASS]

As PR113206 and PR113209, the bugs happens on the following situation:

        li      a4,32
	...
	vsetvli zero,a4,e8,m8,ta,ma
	...
        slliw   a4,a3,24
        sraiw   a4,a4,24
        bge     a3,a1,.L8
        sb      a4,%lo(e)(a0)
        vsetvli zero,a4,e8,m8,ta,ma  --> a4 is polluted value not the expected "32".
	...
.L7:
        j       .L7 ---> infinite loop.

The root cause is that infinite loop confuse earliest computation and let earliest fusion
happens on unexpected place.

Disable blocks that belong to infinite loop to fix this bug since applying ealiest LCM fusion
on infinite loop seems quite complicated and we don't see any benefits.

Note that disabling earliest fusion on infinite loops doesn't hurt the vsetvli performance,
instead, it does improve codegen of some cases.

Tested on both RV32 and RV64 no regression.

	PR target/113206
	PR target/113209

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc (invalid_opt_bb_p): New function.
	(pre_vsetvl::compute_lcm_local_properties): Disable earliest fusion on
	blocks belong to infinite loop.
	(pre_vsetvl::emit_vsetvl): Remove fake edges.
	* config/riscv/t-riscv: Add a new include file.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/vsetvl/avl_single-23.c: Adapt test.
	* gcc.target/riscv/rvv/vsetvl/vlmax_call-1.c: Robostify test.
	* gcc.target/riscv/rvv/vsetvl/vlmax_call-2.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/vlmax_call-3.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-5.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-1.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-2.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-3.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-4.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-5.c: Ditto.
	* gcc.target/riscv/rvv/autovec/pr113206-1.c: New test.
	* gcc.target/riscv/rvv/autovec/pr113206-2.c: New test.
	* gcc.target/riscv/rvv/autovec/pr113209.c: New test.
parent 97c1f176
No related branches found
No related tags found
No related merge requests found
Showing
with 166 additions and 50 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment