public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Reload bug
@ 2003-04-08 18:52 Eric Botcazou
  2003-04-08 23:16 ` Jan Hubicka
  2003-04-09  9:13 ` Eric Botcazou
  0 siblings, 2 replies; 41+ messages in thread
From: Eric Botcazou @ 2003-04-08 18:52 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc

[-- Attachment #1: Type: text/plain, Size: 1766 bytes --]

Hello Jan,

I've narrowed down the bug reported as PR optimization/10233, a regression 
from GCC 3.2 present on the 3.2 branch since 3.2.1 (but latent on all active 
branches), to this patch

Thu Oct 17 17:14:07 CEST 2002  Jan Hubicka  <jh@suse.cz>

	PR opt/7630
	* reload.c (reload_inner_reg_of_subreg): New argument output;
	(push_reload): Update call.


We are trying to reload

	(subreg:SI (reg/v:DI 29 rmm0 [68]) 4)

as the 'in' argument of push_reload.

Before your patch, the compiler correctly detected that the whole register 
needs to be reloaded because we can't access the high part of MMX regs.

But now reload_inner_reg_of_subreg returns 0 for this subreg because its 
return value depends upon the context: if we pass it an 'in' argument, it 
will not check the following condition

  /* If the outer part is a word or smaller, INNER larger than a
     word and the number of regs for INNER is not the same as the
     number of words in INNER, then INNER will need reloading.  */

which happens to apply to this subreg.

Then the subsequent logic is fooled and we end up reloading

	(reg/v:SI 29 emm0)


The rationale for the patch is there:
http://gcc.gnu.org/ml/gcc-patches/2002-10/msg00628.html

The last sentence: "However it is completely irrelevant for input operand in 
all cases - we always can move just the small part of register and use it 
directly, so I've added new operand to bypass this logic in the input 
operand case."

Did you intend to disable the condition for low parts only? (there appears to 
be no testcase associated with the patch so it's hard to tell). If so, does 
the following patch fit your needs?

-- 
Eric Botcazou


	* reload.c (reload_inner_reg_of_subreg): Require reloading for
	non-low parts of input operands.

[-- Attachment #2: pr10233.diff --]
[-- Type: text/x-diff, Size: 1007 bytes --]

Index: reload.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload.c,v
retrieving revision 1.178.2.4.2.6
diff -u -p -r1.178.2.4.2.6 reload.c
--- reload.c	29 Mar 2003 19:30:39 -0000	1.178.2.4.2.6
+++ reload.c	8 Apr 2003 17:40:34 -0000
@@ -826,10 +826,12 @@ reload_inner_reg_of_subreg (x, mode, out
      word and the number of regs for INNER is not the same as the
      number of words in INNER, then INNER will need reloading.  */
   return (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
-	  && output
 	  && GET_MODE_SIZE (GET_MODE (inner)) > UNITS_PER_WORD
 	  && ((GET_MODE_SIZE (GET_MODE (inner)) / UNITS_PER_WORD)
-	      != HARD_REGNO_NREGS (REGNO (inner), GET_MODE (inner))));
+	      != HARD_REGNO_NREGS (REGNO (inner), GET_MODE (inner)))
+	  /* This is not necessary for low parts of input operands
+	     because we can always access them directly.  */
+	  && (output || ! subreg_lowpart_p (x)));
 }
 
 /* Record one reload that needs to be performed.

^ permalink raw reply	[flat|nested] 41+ messages in thread
* Reload bug
@ 1999-09-01  8:40 Andreas Schwab
  1999-09-02  0:32 ` Jeffrey A Law
  1999-09-30 18:02 ` Andreas Schwab
  0 siblings, 2 replies; 41+ messages in thread
From: Andreas Schwab @ 1999-09-01  8:40 UTC (permalink / raw)
  To: gcc

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1993 bytes --]

The following function generates a compiler crash in final:

$ cat random.c
unsigned int GetRandom (void);

long long
Default_RandInt (long long Max)
{
  long long f, m, r, a, b;
  long long s;

  do
    {
      m = Max;
      s = 0;
      f = 1;
      while (m > 1)
	{
	  if (m >= 4294967296)
	    r = GetRandom ();
	  else
	    {
	      a = 4294967296 - 4294967296 % m;
	      do
		b = GetRandom ();
	      while (!(b < a));
	      r = b % m;
	    }
	  s += r * f;
	  f = f * 4294967296;
	  m = (m - 1) / 4294967296 + 1;
	}
    }
  while (!(s < Max || Max == 0));

  return s;
}
$ b=/cvs/test/i686-linux/egcs/gcc; $b/xgcc -B$b/ -O2 -fpic -S random.c -da
random.c: In function `Default_RandInt':
random.c:34: Internal compiler error in `change_address', at emit-rtl.c:1516
Please submit a full bug report.
See <URL: http://www.gnu.org/software/gcc/faq.html#bugreport > for instructions.

The problem is in the following two insns:

(insn 256 254 10 (set (reg:DI 31)
        (mem/u:DI (plus:SI (reg:SI 3 %ebx)
                (const (unspec[ 
                            (symbol_ref/u:SI ("*.LC0"))
                        ]  7))) 0)) 79 {movdi+1} (nil)
    (expr_list:REG_EQUIV (const_double (mem/u:DI (symbol_ref/u:SI ("*.LC0")) 0) 0 [0x0] 1 [0x1] 0 [0x0])
        (nil)))

(insn 83 77 85 (parallel[ 
            (set (reg/v:DI 26)
                (minus:DI (reg:DI 31)
                    (reg:DI 38)))
            (clobber (scratch:SI))
        ] ) 215 {subdi3} (insn_list 77 (nil))
    (expr_list:REG_DEAD (reg:DI 38)
        (expr_list:REG_UNUSED (scratch:SI)
            (nil))))

During global alloc register 31 is replaced by (mem:DI (symbol_ref)), but
a symbol_ref is not a valid memory operand due to PIC.  In other words,
register 31 is _not_ equivalent to what insn 256 claims.

-- 
Andreas Schwab                                  "And now for something
schwab@suse.de                                   completely different."
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg

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

end of thread, other threads:[~2003-04-17 21:44 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-08 18:52 Reload bug Eric Botcazou
2003-04-08 23:16 ` Jan Hubicka
2003-04-09  0:44   ` Jan Hubicka
2003-04-09  7:00     ` Eric Botcazou
2003-04-09  3:00   ` Eric Botcazou
2003-04-09  9:49     ` Jan Hubicka
2003-04-09  8:57   ` Eric Botcazou
2003-04-09  9:45     ` Jan Hubicka
2003-04-09  9:50       ` Eric Botcazou
2003-04-09 14:52         ` Jan Hubicka
2003-04-09 18:10           ` Eric Botcazou
2003-04-09 19:15             ` Jan Hubicka
2003-04-10 14:25           ` Eric Botcazou
2003-04-10 16:31             ` Jan Hubicka
2003-04-10 16:35               ` Jan Hubicka
2003-04-10 20:21             ` Eric Botcazou
2003-04-10 20:43               ` Jan Hubicka
2003-04-11 14:44                 ` Eric Botcazou
2003-04-11 17:49                   ` Jan Hubicka
2003-04-11 18:09                   ` Jan Hubicka
2003-04-11 19:01                   ` Jan Hubicka
2003-04-11 19:07                   ` Jan Hubicka
2003-04-12 14:55                     ` Eric Botcazou
2003-04-12 17:45                       ` Jan Hubicka
2003-04-13 19:57                         ` Eric Botcazou
2003-04-13 20:04                           ` Jan Hubicka
2003-04-12 17:55                       ` Make reload to avoid invalid subregs Jan Hubicka
2003-04-17 22:32                         ` Richard Henderson
2003-04-10 20:51               ` Reload bug Dale Johannesen
2003-04-09  9:13 ` Eric Botcazou
2003-04-09 11:25   ` Jan Hubicka
2003-04-09 12:04     ` Eric Botcazou
2003-04-09 18:05       ` Jan Hubicka
2003-04-09 18:26         ` Eric Botcazou
2003-04-09 21:23         ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
1999-09-01  8:40 Andreas Schwab
1999-09-02  0:32 ` Jeffrey A Law
1999-09-02  2:15   ` Andreas Schwab
1999-09-30 18:02     ` Andreas Schwab
1999-09-30 18:02   ` Jeffrey A Law
1999-09-30 18:02 ` Andreas Schwab

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