lra: Fix up debug_p handling in lra_substitute_pseudo [PR104778]
authorJakub Jelinek <jakub@redhat.com>
Mon, 14 Mar 2022 13:49:09 +0000 (14:49 +0100)
committerJakub Jelinek <jakub@redhat.com>
Mon, 14 Mar 2022 13:49:09 +0000 (14:49 +0100)
commit77eb0461abe61a85f69270048ad81b25b1cc95d6
treeb0451db695ef69ebc0e544054005af10123c425f
parent8f7b7c1495f92c72da154d32317943a2cc276ca8
lra: Fix up debug_p handling in lra_substitute_pseudo [PR104778]

The following testcase ICEs on powerpc-linux, because lra_substitute_pseudo
substitutes (const_int 1) into a subreg operand.  First a subreg of subreg
of a reg appears in a debug insn (which surely is invalid outside of
debug insns, but in debug insns we allow even what is normally invalid in
RTL like subregs which the target doesn't like, because either dwarf2out
is able to handle it, or we just throw away the location expression,
making some var <optimized out>.

lra_substitute_pseudo already has some code to deal with specifically
SUBREG of REG with the REG being substituted for VOIDmode constant,
but that doesn't cover this case, so the following patch extends
lra_substitute_pseudo for debug_p mode to treat stuff like e.g.
combiner's subst function to ensure we don't lose mode which is essential
for the IL.

2022-03-14  Jakub Jelinek  <jakub@redhat.com>

PR debug/104778
* lra.cc (lra_substitute_pseudo): For debug_p mode, simplify
SUBREG, ZERO_EXTEND, SIGN_EXTEND, FLOAT or UNSIGNED_FLOAT if recursive
call simplified the first operand into VOIDmode constant.

* gcc.target/powerpc/pr104778.c: New test.
gcc/lra.cc
gcc/testsuite/gcc.target/powerpc/pr104778.c [new file with mode: 0644]