public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] cselib: Fix endless cselib loop on (plus:P (reg) (const_int 0))
@ 2020-04-06 22:33 Jakub Jelinek
  2020-04-06 22:57 ` Jeff Law
  2020-04-07 22:35 ` Joseph Myers
  0 siblings, 2 replies; 4+ messages in thread
From: Jakub Jelinek @ 2020-04-06 22:33 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

Hi!

getopt.c hangs the compiler on h8300-elf with -O2 -g, because the
IL contains addition of constant 0, the first PLUS operand is determined
to have the SP_DERIVED_VALUE_P and the new code in cselib recurses
indefinitely on seeing SP_DERIVED_VALUE_P with locs of
(plus:P SP_DERIVED_VALUE_P (const_int 0)).

Fixed by making sure cselib_subst_to_values canonicalizes it, hashing
already hashes it the same too.

Bootstrapped/regtested on x86_64-linux and i686-linux, tested on the
getopt.i testcase using cross to h8300-elf, approved off-list by Jeff,
committed to trunk.

2020-04-06  Jakub Jelinek  <jakub@redhat.com>

	* cselib.c (cselib_subst_to_values): For SP_DERIVED_VALUE_P
	+ const0_rtx return the SP_DERIVED_VALUE_P.

--- gcc/cselib.c.jj	2020-04-04 10:31:15.409783959 +0200
+++ gcc/cselib.c	2020-04-06 12:05:46.055767835 +0200
@@ -2090,13 +2090,17 @@ cselib_subst_to_values (rtx x, machine_m
 	{
 	  rtx t = cselib_subst_to_values (XEXP (x, 0), memmode);
 	  if (GET_CODE (t) == VALUE)
-	    for (struct elt_loc_list *l = CSELIB_VAL_PTR (t)->locs;
-		 l; l = l->next)
-	      if (GET_CODE (l->loc) == PLUS
-		  && GET_CODE (XEXP (l->loc, 0)) == VALUE
-		  && SP_DERIVED_VALUE_P (XEXP (l->loc, 0))
-		  && CONST_INT_P (XEXP (l->loc, 1)))
-		return plus_constant (Pmode, l->loc, INTVAL (XEXP (x, 1)));
+	    {
+	      if (SP_DERIVED_VALUE_P (t) && XEXP (x, 1) == const0_rtx)
+		return t;
+	      for (struct elt_loc_list *l = CSELIB_VAL_PTR (t)->locs;
+		   l; l = l->next)
+		if (GET_CODE (l->loc) == PLUS
+		    && GET_CODE (XEXP (l->loc, 0)) == VALUE
+		    && SP_DERIVED_VALUE_P (XEXP (l->loc, 0))
+		    && CONST_INT_P (XEXP (l->loc, 1)))
+		  return plus_constant (Pmode, l->loc, INTVAL (XEXP (x, 1)));
+	    }
 	  if (t != XEXP (x, 0))
 	    {
 	      copy = shallow_copy_rtx (x);

	Jakub


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

* Re: [committed] cselib: Fix endless cselib loop on (plus:P (reg) (const_int 0))
  2020-04-06 22:33 [committed] cselib: Fix endless cselib loop on (plus:P (reg) (const_int 0)) Jakub Jelinek
@ 2020-04-06 22:57 ` Jeff Law
  2020-04-07 22:35 ` Joseph Myers
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff Law @ 2020-04-06 22:57 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Tue, 2020-04-07 at 00:33 +0200, Jakub Jelinek wrote:
> Hi!
> 
> getopt.c hangs the compiler on h8300-elf with -O2 -g, because the
> IL contains addition of constant 0, the first PLUS operand is determined
> to have the SP_DERIVED_VALUE_P and the new code in cselib recurses
> indefinitely on seeing SP_DERIVED_VALUE_P with locs of
> (plus:P SP_DERIVED_VALUE_P (const_int 0)).
> 
> Fixed by making sure cselib_subst_to_values canonicalizes it, hashing
> already hashes it the same too.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, tested on the
> getopt.i testcase using cross to h8300-elf, approved off-list by Jeff,
> committed to trunk.
> 
> 2020-04-06  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* cselib.c (cselib_subst_to_values): For SP_DERIVED_VALUE_P
> 	+ const0_rtx return the SP_DERIVED_VALUE_P.
Thanks.  And just FTR, the scenario where this happens could (in theory) happen
on other ports, particularly those still using reload.

jeff
> 


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

* Re: [committed] cselib: Fix endless cselib loop on (plus:P (reg) (const_int 0))
  2020-04-06 22:33 [committed] cselib: Fix endless cselib loop on (plus:P (reg) (const_int 0)) Jakub Jelinek
  2020-04-06 22:57 ` Jeff Law
@ 2020-04-07 22:35 ` Joseph Myers
  2020-04-07 22:42   ` Jeff Law
  1 sibling, 1 reply; 4+ messages in thread
From: Joseph Myers @ 2020-04-07 22:35 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Jeff Law, gcc-patches

This introduces an ICE building glibc for m68k (and the same ICE appears 
for microblaze, though I haven't bisected there).  See bug 94526.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [committed] cselib: Fix endless cselib loop on (plus:P (reg) (const_int 0))
  2020-04-07 22:35 ` Joseph Myers
@ 2020-04-07 22:42   ` Jeff Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2020-04-07 22:42 UTC (permalink / raw)
  To: Joseph Myers, Jakub Jelinek; +Cc: gcc-patches

On Tue, 2020-04-07 at 22:35 +0000, Joseph Myers wrote:
> This introduces an ICE building glibc for m68k (and the same ICE appears 
> for microblaze, though I haven't bisected there).  See bug 94526.
Yea, I've already forwarded Jakub the microblaze testcase.

jeff


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

end of thread, other threads:[~2020-04-07 22:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 22:33 [committed] cselib: Fix endless cselib loop on (plus:P (reg) (const_int 0)) Jakub Jelinek
2020-04-06 22:57 ` Jeff Law
2020-04-07 22:35 ` Joseph Myers
2020-04-07 22:42   ` Jeff Law

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