]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PR target/123911][RISC-V] Fix infinite recursion in riscv_legitimize_move
authorJeff Law <jeffrey.law@oss.qualcomm.com>
Sun, 8 Feb 2026 15:23:07 +0000 (08:23 -0700)
committerJeff Law <jeffrey.law@oss.qualcomm.com>
Mon, 9 Feb 2026 02:35:53 +0000 (19:35 -0700)
commit2f84ad4ddc2a2dc93584d87da347c444a77f429c
treebcf9b137350e7820fb4e0dc012b082cf40e49baa
parent08a17b96c31f78bf7d030f5550ef801580a178ed
[PR target/123911][RISC-V] Fix infinite recursion in riscv_legitimize_move

I kept hoping I'd see a better solution, perhaps one where chunks of this
routine just go away, but that hasn't materialized.  So...

This patch avoids infinite recursion through riscv_legitimize_move.
Essentially we end up calling it recursively with arguments that are a nop-move
and those particular arguments trigger infinite recursion.

So this patch just recognizes and elides the nop move.   Bootstrapped on
riscv64-linux-gnu and regression tested on riscv{32,64}-elf with no
regressions.  Pushing to the trunk.

PR target/123911
gcc/
* config/riscv/riscv.cc (riscv_legitimize_move): Elide nop moves to
avoid infinite recursion.

gcc/testsuite/
* gcc.target/riscv/pr123911.c: New test.
gcc/config/riscv/riscv.cc
gcc/testsuite/gcc.target/riscv/pr123911.c [new file with mode: 0644]