public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Non-representable subregs of subword pseudoregs
@ 2004-11-13 13:17 Eric Botcazou
  2004-11-13 13:45 ` Jan Hubicka
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Eric Botcazou @ 2004-11-13 13:17 UTC (permalink / raw)
  To: gcc; +Cc: Jan Hubicka

Hello,

I've run into a surprising (to me) behavior of the reload pass: it apparently 
doesn't know how to reload non-representable subregs of subword pseudoregs.
For example on SPARC64:

(insn 22 21 23 1 (set (reg:SI 109 [ D.1130 ])
        (subreg:SI (reg:DI 126) 0)) 51 {*movsi_insn} (nil)
    (nil))

leads to

Reloads for insn # 22
Reload 0: reload_in (SI) = (reg:SI 1 %g1)
	GENERAL_REGS, RELOAD_FOR_INPUT (opnum = 1), can't combine
	reload_in_reg: (subreg:SI (reg:DI 1 %g1 [126]) 0)
	reload_reg_rtx: (reg:SI 5 %g5)

(insn 61 21 22 1 (set (reg:SI 5 %g5)
        (reg:SI 1 %g1)) 51 {*movsi_insn} (nil)
    (nil))

(insn 22 61 23 1 (set (reg:SI 4 %g4 [orig:109 D.1130 ] [109])
        (reg:SI 5 %g5)) 51 {*movsi_insn} (nil)
    (nil))

which is of course wrong since the target is big-endian.


A reload is scheduled because find_reload correctly diagnoses that the subreg 
is not representable:

	  while (GET_CODE (operand) == SUBREG)
	    {
	      /* Offset only matters when operand is a REG and
		 it is a hard reg.  This is because it is passed
		 to reg_fits_class_p if it is a REG and all pseudos
		 return 0 from that function.  */
	      if (REG_P (SUBREG_REG (operand))
		  && REGNO (SUBREG_REG (operand)) < FIRST_PSEUDO_REGISTER)
		{
		  if (!subreg_offset_representable_p
			(REGNO (SUBREG_REG (operand)),
			 GET_MODE (SUBREG_REG (operand)),
			 SUBREG_BYTE (operand),
			 GET_MODE (operand)))
		     force_reload = 1;

However, reload_inner_reg_of_subreg returns false for it (for 2 reasons: it's 
an input reload and the function only looks at output reloads, and subregs of 
subword regs are rejected) so push_reload silently turns the invalid subreg 
into the low part:

  /* If IN is a SUBREG of a hard register, make a new REG.  This
     simplifies some of the cases below.  */

  if (in != 0 && GET_CODE (in) == SUBREG && REG_P (SUBREG_REG (in))
      && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER
      && ! dont_remove_subreg)
    in = gen_rtx_REG (GET_MODE (in), subreg_regno (in));


Is this a known limitation of the reload pass or am I missing anything else?
[Jan, I've CCed you because you devised subreg_offset_representable_p.]


The non-representable subreg is created by emit_move_insn_1 when it is invoked 
on pseudo regs and CONCATs with complex modes.  Note that it already has a 
special provision in order not to create non-representable subregs of hard 
regs:

	  /* If this is a complex value with each part being smaller than a
	     word, the usual calling sequence will likely pack the pieces into
	     a single register.  Unfortunately, SUBREG of hard registers only
	     deals in terms of words, so we have a problem converting input
	     arguments to the CONCAT of two registers that is used elsewhere
	     for complex values.  If this is before reload, we can copy it into
	     memory and reload.  FIXME, we should see about using extract and
	     insert on integer registers, but complex short and complex char
	     variables should be rarely used.  */
	  if (GET_MODE_BITSIZE (mode) < 2 * BITS_PER_WORD
	      && (reload_in_progress | reload_completed) == 0)
	    {
	      int packed_dest_p
		= (REG_P (x) && REGNO (x) < FIRST_PSEUDO_REGISTER);
	      int packed_src_p
		= (REG_P (y) && REGNO (y) < FIRST_PSEUDO_REGISTER);

	      if (packed_dest_p || packed_src_p)

but it doesn't apply here because we are dealing with pseudo regs.


How is this supposed to work?  Is it simply illegal to create non-lowpart 
subregs of subword pseudo regs?

Thanks in advance.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: Non-representable subregs of subword pseudoregs
@ 2004-11-13 19:24 Ulrich Weigand
  2004-11-13 20:24 ` Eric Botcazou
  0 siblings, 1 reply; 15+ messages in thread
From: Ulrich Weigand @ 2004-11-13 19:24 UTC (permalink / raw)
  To: ebotcazou; +Cc: gcc, jh

Eric Botcazou wrote:

>For example on SPARC64:
(I assume this has word_mode == DImode?)

>(insn 22 21 23 1 (set (reg:SI 109 [ D.1130 ])
>        (subreg:SI (reg:DI 126) 0)) 51 {*movsi_insn} (nil)
>    (nil))

While there's unfortunately some amount of confusion as to which
subregs are valid, exactly, I think it should be pretty clear
that *this* subreg is certainly *not* valid.

As per the documentation, subregs can be used to denote either
- a value re-interpreted in another mode (this always means lowpart)
or
- one of the words of a multi-word value (i.e. > word_mode)
or
- a combination of the two (a lowpart of one word of a multi-word)

Since (reg:DI 126) is a single-word value, and the subreg does
not denote the lowpart, it should be invalid.


>Is it simply illegal to create non-lowpart 
>subregs of subword pseudo regs?

I think so, yes.


Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  Linux on zSeries Development
  Ulrich.Weigand@de.ibm.com

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

end of thread, other threads:[~2004-11-14 10:41 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-13 13:17 Non-representable subregs of subword pseudoregs Eric Botcazou
2004-11-13 13:45 ` Jan Hubicka
2004-11-13 22:55 ` Richard Sandiford
2004-11-13 23:31   ` Eric Botcazou
2004-11-13 23:06 ` [cft] subreg validation patch Richard Henderson
2004-11-13 23:50   ` Eric Botcazou
2004-11-14  0:02     ` Richard Henderson
2004-11-14  0:21       ` Eric Botcazou
2004-11-14  4:41         ` Richard Henderson
2004-11-14  5:12     ` Richard Henderson
2004-11-14  6:14       ` Geert Bosch
2004-11-14  7:46       ` Richard Henderson
2004-11-14 10:50         ` Eric Botcazou
2004-11-13 19:24 Non-representable subregs of subword pseudoregs Ulrich Weigand
2004-11-13 20:24 ` Eric Botcazou

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).