public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Undocumented anomaly with EXTRA_CONSTRAINTS
@ 2002-04-09  5:19 David S. Miller
  2002-04-09  6:21 ` Michael Matz
  0 siblings, 1 reply; 5+ messages in thread
From: David S. Miller @ 2002-04-09  5:19 UTC (permalink / raw)
  To: gcc


As per the documentation and usage, EXTRA_CONSTRANT is for
"Special cases of registers or memory."

Fine so far, but one has to be really careful when using
this for memory operands.  Specifically I just fixed a bug
(patch to gcc-patches and commit to come after my regressions
run) in the Sparc port that appears to be present in other
ports as well.

Consider how constrain_operands works, and also how reload
checks the constraints.  In particular, look at how the 'm'
works.  In constrain_operands it passes if:

	GET_CODE (op) == MEM
	/* Before reload, accept what reload can turn into mem.  */
	|| (strict < 0 && CONSTANT_P (op))
	/* During reload, accept a pseudo  */
	|| (reload_in_progress && GET_CODE (op) == REG
	    && REGNO (op) >= FIRST_PSEUDO_REGISTER)

In the reload case the test is (let us call this the
REG_OK_STRICT case, since that is what it is):

	GET_CODE (operand) == MEM
	|| (GET_CODE (operand) == REG
	    && REGNO (operand) >= FIRST_PSEUDO_REGISTER
	    && reg_renumber[REGNO (operand)] < 0)

These extra:

	1) accept any pseudo if !REG_OK_STRICT
	2) accept only non-renumbered pseudos if REG_OK_STRICT

checks in their memory EXTRA_CONTRAINT entries aren't documented.

Which means that anyone making a mistake here can end up with "severe
tire damage" in reload.

I note that the PA port specifically makes note of this issue with
it's IS_RELOADING_PSEUDO_P macro.  Hi Jeff. :-)  In fact I want to
quote Jeff's comments in the PA headers above the EXTRA_CONSTRAINT
definition because it sums up my email:

   Note that an unassigned pseudo register is such a memory operand.
   Needed because reload will generate these things in insns and then
   not re-recognize the insns, causing constrain_operands to fail.

Anyways, the gist of my email is:

1) Am I right?
2) Once decided, we should document this and perhaps even
   "help" the port somehow.

By "help" the port, I mean we can somehow hide these recog/reload
details about accepting pseudo-registers for memory constraints.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-04-09 13:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-09  5:19 Undocumented anomaly with EXTRA_CONSTRAINTS David S. Miller
2002-04-09  6:21 ` Michael Matz
2002-04-09  6:24   ` David S. Miller
2002-04-09  6:24   ` David S. Miller
2002-04-09  7:08     ` Michael Matz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).