sparc: Preserve ORIGINAL_REGNO in epilogue_renumber [PR105257]
authorJakub Jelinek <jakub@redhat.com>
Tue, 19 Apr 2022 16:58:59 +0000 (18:58 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 19 Apr 2022 16:58:59 +0000 (18:58 +0200)
commiteeca2b8bd03f57c59c6cf48bf6b9bd6dc86924f6
treeccc98793e6bc5039fe7df862c95a90f5d25eba58
parenteb03e424598d30fed68801af6d6ef6236d32e32e
sparc: Preserve ORIGINAL_REGNO in epilogue_renumber [PR105257]

The following testcase ICEs, because the pic register is
(reg:DI 24 %i0 [109]) and is used in the delay slot of a return.
We invoke epilogue_renumber and that changes it to
(reg:DI 8 %o0) which no longer satisfies sparc_pic_register_p
predicate, so we don't recognize the insn anymore.

The following patch fixes that by preserving ORIGINAL_REGNO if
specified, so we get (reg:DI 8 %o0 [109]) instead.

2022-04-19  Jakub Jelinek  <jakub@redhat.com>

PR target/105257
* config/sparc/sparc.cc (epilogue_renumber): If ORIGINAL_REGNO,
use gen_raw_REG instead of gen_rtx_REG and copy over also
ORIGINAL_REGNO.  Use return 0; instead of /* fallthrough */.

* gcc.dg/pr105257.c: New test.
gcc/config/sparc/sparc.cc
gcc/testsuite/gcc.dg/pr105257.c [new file with mode: 0644]