https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108552
--- Comment #35 from Vladimir Makarov <vmakarov at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #34) > Seems right now DECL_NONALIASED is only used on these coverage vars and on > Fortran caf tokens, so perhaps a quick workaround would be on the LRA side > never reread stuff from MEMs with VAR_P && DECL_NONALIASED MEM_EXPRs. CCing > Vlad on that. The following patch can do this: diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index 7bffbc07ee2..d80a6a9f41d 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -515,6 +515,7 @@ get_equiv (rtx x) { int regno; rtx res; + tree expr; if (! REG_P (x) || (regno = REGNO (x)) < FIRST_PSEUDO_REGISTER || ! ira_reg_equiv[regno].defined_p @@ -525,6 +526,10 @@ get_equiv (rtx x) { if (targetm.cannot_substitute_mem_equiv_p (res)) return x; + if ((expr = MEM_EXPR (res)) != NULL + && (expr = get_base_address (expr)) != NULL + && VAR_P (expr) && DECL_NONALIASED (expr)) + return x; return res; } if ((res = ira_reg_equiv[regno].constant) != NULL_RTX)