]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: fix zcmp popretz [PR113715]
authorFei Gao <gaofei@eswincomputing.com>
Tue, 9 Jul 2024 10:00:29 +0000 (10:00 +0000)
committerFei Gao <gaofei@eswincomputing.com>
Wed, 10 Jul 2024 01:47:36 +0000 (01:47 +0000)
commit7a345d0314f8cf0f15ca3664b1e4430d65764570
treec48831b2342284a823eba95a01537477fa127af5
parent0dcfef42df473c60a2343a66d289f7844edaff1e
RISC-V: fix zcmp popretz [PR113715]

No functional changes compared with V1, just spaces to table conversion
in testcases to pass check-function-bodies.

V1 passed regression locally but suprisingly failed in pre-commit CI, after
picking the patch from patchwork, I realize table got coverted to spaces
before sending the patch.

Root cause:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b27d323a368033f0b37e93c57a57a35fd9997864
Commit above tries in targetm.gen_epilogue () to detect if
there's li a0,0 insn at the end of insn chain, if so, cm.popret
is replaced by cm.popretz and li a0,0 insn is deleted.

Insertion of the generated epilogue sequence
into the insn chain doesn't happen at this moment.
If later shrink-wrap decides NOT to insert the epilogue sequence at the end
of insn chain, then the li a0,0 insn has already been mistakeny removed.

Fix this issue by removing generation of cm.popretz in epilogue,
leaving the assignment to a0 and use insn with cm.popret.

That's likely going to result in some kind of code size regression,
but not a correctness regression.

Optimization can be done in future.

Signed-off-by: Fei Gao <gaofei@eswincomputing.com>
gcc/ChangeLog:
PR target/113715

* config/riscv/riscv.cc (riscv_zcmp_can_use_popretz): Removed.
(riscv_gen_multi_pop_insn): Remove generation of cm.popretz.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rv32e_zcmp.c: Adapt TC.
* gcc.target/riscv/rv32i_zcmp.c: Likewise.
gcc/config/riscv/riscv.cc
gcc/testsuite/gcc.target/riscv/rv32e_zcmp.c
gcc/testsuite/gcc.target/riscv/rv32i_zcmp.c