Bug 36827 - [4.3/4.4/4.5 Regression] newlib:libm/math/k_rem_pio2.c fails in reload
Summary: [4.3/4.4/4.5 Regression] newlib:libm/math/k_rem_pio2.c fails in reload
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.0
: P4 blocker
Target Milestone: 4.3.5
Assignee: Not yet assigned to anyone
URL:
Keywords: build, ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2008-07-14 22:29 UTC by DJ Delorie
Modified: 2010-02-25 00:25 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: m32c-elf
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
preprocessed file for description (4.77 KB, text/plain)
2008-07-14 22:31 UTC, DJ Delorie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description DJ Delorie 2008-07-14 22:29:57 UTC
as of rev 137639:

cc1 -fpreprocessed k_rem_pio2.i -quiet -dumpbase k_rem_pio2.c -auxbase-strip lib_a-k_rem_pio2.o -Os -fno-builtin -o k_rem_pio2.s

src/newlib/libm/math/k_rem_pio2.c: In function '__kernel_rem_pio2':
newlib/libm/math/k_rem_pio2.c:318: error: unable to find a register to spill in class 'A_REGS'
newlib/libm/math/k_rem_pio2.c:318: error: this is the insn:
(jump_insn 1098 1096 2868 9 newlib/libm/math/k_rem_pio2.c:186 (set (pc)
        (if_then_else (gt (subreg:HI (reg/v:SI 1108 [ i ]) 2)
                (subreg:HI (reg/v:SI 1105 [ m ]) 2))
            (label_ref:HI 3007)
            (pc))) 48 {cbranchhi4} (expr_list:REG_BR_PROB (const_int 5000 [0x1388])
        (nil)))
newlib/libm/math/k_rem_pio2.c:318: internal compiler error: in spill_failure, at reload1.c:1995
Comment 1 DJ Delorie 2008-07-14 22:31:08 UTC
Created attachment 15908 [details]
preprocessed file for description
Comment 2 Eric Botcazou 2008-07-14 22:44:41 UTC
Note that the problematic patch has been installed on the 4.3 branch as well.
Comment 3 Jakub Jelinek 2008-07-15 15:19:20 UTC
You mean http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137640 or something else?
Comment 4 DJ Delorie 2008-07-15 15:38:34 UTC
Yes, 137639 and 137640 are the same patch, to trunk and 4.3, respectively.
Comment 5 jsm-csl@polyomino.org.uk 2008-07-15 15:41:15 UTC
Subject: Re:   New: newlib:libm/math/k_rem_pio2.c fails in reload

Please try this patch.  The m32c target seems to be generating its own 
invalid addresses and reloads for them, for reasons I don't quite 
understand, so something like this looks like it's needed to avoid reload 
generating further reloads in those cases.

Index: config/m32c/m32c.c
===================================================================
--- config/m32c/m32c.c	(revision 137836)
+++ config/m32c/m32c.c	(working copy)
@@ -1778,6 +1778,8 @@
 
 /* Addressing Modes */
 
+#define BIG_FB_ADJ 0
+
 /* Used by GO_IF_LEGITIMATE_ADDRESS.  The r8c/m32c family supports a
    wide range of non-orthogonal addressing modes, including the
    ability to double-indirect on *some* of them.  Not all insns
@@ -1895,6 +1897,17 @@
 	  return 0;
 	}
     }
+  if (RTX_IS ("++rii"))
+    {
+      rtx reg = patternr[2];
+      HOST_WIDE_INT offs = INTVAL (patternr[3]);
+
+      /* Avoid reloads for addresses generated by
+	 m32c_legitimize_reload_address being generated by
+	 find_reloads_subreg_address.  */
+      if (REGNO (reg) == FB_REGNO && offs == -BIG_FB_ADJ)
+	return 1;
+    }
   return 0;
 }
 
@@ -1942,8 +1955,6 @@
    frame, so the third case seems best.  Note that we subtract the
    zero, but detect that in the addhi3 pattern.  */
 
-#define BIG_FB_ADJ 0
-
 /* Implements LEGITIMIZE_ADDRESS.  The only address we really have to
    worry about is frame base offsets, as $fb has a limited
    displacement range.  We deal with this by attempting to reload $fb

Comment 6 Jakub Jelinek 2008-07-15 16:01:54 UTC
m32c-elf is neither primary nor secondary target.
Comment 7 DJ Delorie 2008-07-16 02:07:55 UTC
Subject: Re:  [4.3/4.4 Regression] newlib:libm/math/k_rem_pio2.c fails in reload


It fixes the newlib compile failure, but there are regressions since
it last built.  I'll have to check each of them to see if they're
caused by this patch or something else that's happened since then.

Meanwhile, please apply your m32c patch. "newlib doesn't build" is
certainly a bigger problem than "some regressions" :-)

Thanks!
Comment 8 DJ Delorie 2008-07-16 03:04:15 UTC
Subject: Re:  [4.3/4.4 Regression] newlib:libm/math/k_rem_pio2.c fails in reload


The regressions all show up in v850 and iq2000 too, except one that I
can't reproduce, so I'm not going to worry about them.
Comment 9 Joseph S. Myers 2008-07-16 10:46:45 UTC
Subject: Bug 36827

Author: jsm28
Date: Wed Jul 16 10:45:57 2008
New Revision: 137875

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137875
Log:
	PR target/36827
	* config/m32c/m32c.c (BIG_FB_ADJ): Move definition earlier.
	(m32c_legitimate_address_p): Handle "++rii" addresses created by
	m32c_legitimize_reload_address.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/m32c/m32c.c

Comment 10 Joseph S. Myers 2008-07-16 10:47:16 UTC
Subject: Bug 36827

Author: jsm28
Date: Wed Jul 16 10:46:32 2008
New Revision: 137876

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137876
Log:
	PR target/36827
	* config/m32c/m32c.c (BIG_FB_ADJ): Move definition earlier.
	(m32c_legitimate_address_p): Handle "++rii" addresses created by
	m32c_legitimize_reload_address.

Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/m32c/m32c.c

Comment 11 DJ Delorie 2008-07-16 19:08:35 UTC
Subject: Re:  [4.3/4.4 Regression] newlib:libm/math/k_rem_pio2.c fails in reload


Last night's builds showed a flaw in the patch.  The "++rii" address
created by m32c_legitimize_reload_address is *not* legitimate, it's
used as a marker for addresses that need to be reloaded into an
address register.  If I fix m32c_print_operand() to print those, it
ends up printing an address that exceeds the displacement range of the
FB register:

regex.s:11903: Error: unrecognized keyword/register name `mov.w mem0,-198[fb]'

The original idea was to reload $fb of $sp itself into an address
register, and use a displacement off that, so that only one address
register is needed for all frame address reloads.  I never quite got
gcc to do it right.
Comment 12 jsm-csl@polyomino.org.uk 2008-07-16 20:25:03 UTC
Subject: Re:  [4.3/4.4 Regression] newlib:libm/math/k_rem_pio2.c
 fails in reload

On Wed, 16 Jul 2008, dj at redhat dot com wrote:

> Last night's builds showed a flaw in the patch.  The "++rii" address
> created by m32c_legitimize_reload_address is *not* legitimate, it's
> used as a marker for addresses that need to be reloaded into an
> address register.  If I fix m32c_print_operand() to print those, it
> ends up printing an address that exceeds the displacement range of the
> FB register:

Try changing the "reloaded != 1" condition in find_reloads_subreg_address 
to "reloaded == 0" (as a replacement for my m32c patch, and probably for 
the SH patch as well).  I hope that should avoid these problems in the 
cases where LEGITIMIZE_RELOAD_ADDRESS does something like this, and I've 
verified the original ARM testcase that motivated my reload change still 
works with that change.

Comment 13 Kazumoto Kojima 2008-07-17 02:08:37 UTC
> Try changing the "reloaded != 1" condition in find_reloads_subreg_address 
> to "reloaded == 0" (as a replacement for my m32c patch, and probably for 
> the SH patch as well).  I hope that should avoid these problems in the 
> cases where LEGITIMIZE_RELOAD_ADDRESS does something like this, and I've 
> verified the original ARM testcase that motivated my reload change still 
> works with that change.

This works fine on SH.  With this and backing out the workaround
in GO_IF_LEGITIMATE_ADDRESS, sh4-unknown-linux-gnu cross x86 is
built successfully and the result of regtest looks very clean.


Comment 14 DJ Delorie 2008-07-18 00:22:34 UTC
Subject: Re:  [4.3/4.4 Regression] newlib:libm/math/k_rem_pio2.c fails in reload


Seems to work for m32c too.
Comment 15 Joseph S. Myers 2008-07-19 11:15:02 UTC
Subject: Bug 36827

Author: jsm28
Date: Sat Jul 19 11:14:13 2008
New Revision: 137976

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137976
Log:
	PR target/36780
	PR target/36827
	* reload.c (find_reloads_subreg_address): Only reload address if
	reloaded == 0, not for reloaded != 1.

	Revert:
	2008-07-16  Joseph Myers  <joseph@codesourcery.com>
	* config/m32c/m32c.c (BIG_FB_ADJ): Move definition earlier.
	(m32c_legitimate_address_p): Handle "++rii" addresses created by
	m32c_legitimize_reload_address.

	2008-07-15  Kaz Kojima  <kkojima@gcc.gnu.org>
	* config/sh/sh.h (GO_IF_LEGITIMATE_ADDRESS): Allow
	(plus (plus (reg) (const_int)) (const_int)) when reload_in_progress.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/m32c/m32c.c
    trunk/gcc/config/sh/sh.h
    trunk/gcc/reload.c

Comment 16 Joseph S. Myers 2008-07-19 11:16:20 UTC
Subject: Bug 36827

Author: jsm28
Date: Sat Jul 19 11:15:29 2008
New Revision: 137977

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137977
Log:
	PR target/36780
	PR target/36827
	* reload.c (find_reloads_subreg_address): Only reload address if
	reloaded == 0, not for reloaded != 1.

	Revert:
	2008-07-16  Joseph Myers  <joseph@codesourcery.com>
	* config/m32c/m32c.c (BIG_FB_ADJ): Move definition earlier.
	(m32c_legitimate_address_p): Handle "++rii" addresses created by
	m32c_legitimize_reload_address.

	2008-07-15  Kaz Kojima  <kkojima@gcc.gnu.org>
	* config/sh/sh.h (GO_IF_LEGITIMATE_ADDRESS): Allow
	(plus (plus (reg) (const_int)) (const_int)) when reload_in_progress.

Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/m32c/m32c.c
    branches/gcc-4_3-branch/gcc/config/sh/sh.h
    branches/gcc-4_3-branch/gcc/reload.c

Comment 17 Andrew Pinski 2008-08-11 00:54:13 UTC
Isn't this fixed now?
Comment 18 Joseph S. Myers 2008-08-27 22:05:12 UTC
4.3.2 is released, changing milestones to 4.3.3.
Comment 19 Richard Biener 2009-01-24 10:20:36 UTC
GCC 4.3.3 is being released, adjusting target milestone.
Comment 20 Richard Biener 2009-08-04 12:29:18 UTC
GCC 4.3.4 is being released, adjusting target milestone.
Comment 21 Jeffrey A. Law 2010-02-25 00:25:00 UTC
Fixed long ago.  m32c is building newlib without difficulties now.