This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] for PR 22509
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 4 Nov 2005 11:03:34 +0100
- Subject: [patch] for PR 22509
Hello,
this PR is caused by the fact that local_alloc may create invalid
REG_EQUIV notes (that are later used by greg for rematerialization).
In particular, if there is a code like
reg = something;
call (); {pure but not const}
memory = reg;
it will add REG_EQUIV(memory) note on the reg assignment. Greg later
turns it into
memory = something;
call ();
which is wrong in case call reads the memory. This patch adds the
missing check to memref_used_between_p (the reason this problem does
not appear more often is that if the function is not pure, lreg will
note earlier that the memory may be modified by it).
Bootstrapped & regtested on i686 and x86_64.
Zdenek
PR rtl-optimization/22509
* local-alloc.c (memref_used_between_p): Check whether a function call
could not reference the memref.
Index: local-alloc.c
===================================================================
*** local-alloc.c (revision 106319)
--- local-alloc.c (working copy)
*************** memref_used_between_p (rtx memref, rtx s
*** 762,769 ****
for (insn = NEXT_INSN (start); insn != NEXT_INSN (end);
insn = NEXT_INSN (insn))
! if (INSN_P (insn) && memref_referenced_p (memref, PATTERN (insn)))
! return 1;
return 0;
}
--- 762,780 ----
for (insn = NEXT_INSN (start); insn != NEXT_INSN (end);
insn = NEXT_INSN (insn))
! {
! if (!INSN_P (insn))
! continue;
!
! if (memref_referenced_p (memref, PATTERN (insn)))
! return 1;
!
! /* Nonconst functions may access memory. */
! if (CALL_P (insn)
! && (! CONST_OR_PURE_CALL_P (insn)
! || pure_call_p (insn)))
! return 1;
! }
return 0;
}