CC to both the combine maintainer and the RA maintainer for
verdict on whether this is the true correction or just a
"fix"; whether REG_POINTER must be present or is just an
optimization hint.  And I almost forgot, the late-combine
author!  At least I hope to clarify the commit log based on
your replies.  Please also see PR115883.

Tested cris-elf, where the ICEs are gone.  Test-results need another
patch to be restored ante late-combine, though.  Also regtested native
x86_64-pc-linux-gnu.

Ok to commit?

-- >8 --
The first of the late-combine passes, propagates some of the copies
made during the (in-time-)combine pass in make_more_copies into the
users of the "original" pseudo registers and removes the "old"
pseudos.  That effectively removes attributes such as REG_POINTER,
which matter to LRA.  I *think* the actual bug causing the ICEs in the
PR is in LRA.  Either that, or this is the actual bug and REG_POINTER
*must* be present for registers used to form base addresses going into
IRA and LRA.  But the documentation doesn't support that claim,
AFAICS.

Anyway, this patch corrects state for those propagated uses to ante
late-combine.

        PR middle-end/115883
        * combine.cc (make_more_copies): Copy attributes from the original
        pseudo to the new copy.
---
 gcc/combine.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/combine.cc b/gcc/combine.cc
index 3b50bc3529c4..6e6e710aae08 100644
--- a/gcc/combine.cc
+++ b/gcc/combine.cc
@@ -15102,6 +15102,12 @@ make_more_copies (void)
            continue;
 
          rtx new_reg = gen_reg_rtx (GET_MODE (dest));
+
+         // The "original" pseudo copies have important attributes
+         // attached, like pointerness.  We want that for these copies
+         // too, for use by insn recognition and later passes.
+         set_reg_attrs_from_value (new_reg, dest);
+
          rtx_insn *new_insn = gen_move_insn (new_reg, src);
          SET_SRC (set) = new_reg;
          emit_insn_before (new_insn, insn);
-- 
2.30.2

Reply via email to