]>
git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/config/riscv/riscv-vsetvl.cc
RISC-V: fix vsetvli pass testsuite failure [PR/112447]
Fixes: f0e28d8c1371 ("RISC-V: Fix failed hoist in LICM of vmv.v.x instruction")
Since above commit, we have following failure:
FAIL: gcc.c-torture/execute/memset-3.c -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions execution test
FAIL: gcc.c-torture/execute/memset-3.c -O3 -g execution test
The issue was not the commit but rather it unravelled an issue in the
vsetvli pass.
Here's Juzhe's analysis:
We have 2 types of global vsetvls insertion.
One is earliest fusion of each end of the block.
The other is LCM suggested edge vsetvls.
So before this patch, insertion as follows:
| (insn 2817 2820 2818 361 (set (reg:SI 67 vtype)
| (unspec:SI [
| (const_int 8 [0x8])
| (const_int 7 [0x7])
| (const_int 1 [0x1]) repeated x2
| ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
| (nil))
| (insn 2818 2817 999 361 (set (reg:SI 67 vtype)
| (unspec:SI [
| (const_int 32 [0x20])
| (const_int 1 [0x1]) repeated x3
| ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
| (nil))
After this patch:
| (insn 2817 2820 2819 361 (set (reg:SI 67 vtype)
| (unspec:SI [
| (const_int 32 [0x20])
| (const_int 1 [0x1]) repeated x3
| ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
| (nil))
| (insn 2819 2817 999 361 (set (reg:SI 67 vtype)
| (unspec:SI [
| (const_int 8 [0x8])
| (const_int 7 [0x7])
| (const_int 1 [0x1]) repeated x2
| ] UNSPEC_VSETVL)) 1708 {vsetvl_vtype_change_only}
| (nil))
The original insertion order is incorrect.
We should first insert earliest fusion since it is the vsetvls information
already there which was seen by later LCM. We just delay the insertion.
So it should be come before the LCM suggested insertion.
PR target/112447
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (pre_vsetvl::emit_vsetvl): Insert
local vsetvl info before LCM suggested one.
Tested-by: Patrick O'Neill <patrick@rivosinc.com> # pre-commit-CI #679
Co-developed-by: Vineet Gupta <vineetg@rivosinc.com>