public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Question about SUBREG handling in get_last_value
@ 2001-11-19  3:26 John David Anglin
  2001-11-19  9:14 ` Richard Henderson
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: John David Anglin @ 2001-11-19  3:26 UTC (permalink / raw)
  To: gcc

In looking at the testresults for hppa64-hp-hpux11.00, there are a few
FAILs due to aborts in simplify_gen_subreg when it is called with
innermode==VOIDmode.  This happens for example in compile/20000420-2.c
at -O1.

The problem arises with this situation in get_last_value:

(gdb) p debug_rtx (x)

(subreg:SI (reg:DI 28 %r28) 4)

(gdb) p debug_rtx (reg_last_set_value[28])

(call (clobber:SI (const_int 0 [0x0]))
    (const_int 64 [0x40]))

As can be seen, the last value is VOIDmode and the attempt to
simplify it in gen_lowpart_for_combine leads to the abort.  It
looks like `clobber:SI (const_int 0 [0x0])' might have been
substituted before the call to last value where the abort
occurs.

Should get_last_value not call gen_lowpart_for_combine when the
last value is VOIDmode or does gen_lowpart_for_combine need fixing
so it doesn't call simplify_gen_subreg with innermode=VOIDmode?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: Question about SUBREG handling in get_last_value
  2001-11-19  3:26 Question about SUBREG handling in get_last_value John David Anglin
@ 2001-11-19  9:14 ` Richard Henderson
  2001-11-19 14:38   ` John David Anglin
  2001-11-27 13:56   ` Richard Henderson
  2001-11-20 16:13 ` Jan Hubicka
  2001-11-27 10:32 ` John David Anglin
  2 siblings, 2 replies; 12+ messages in thread
From: Richard Henderson @ 2001-11-19  9:14 UTC (permalink / raw)
  To: John David Anglin; +Cc: gcc

On Tue, Nov 27, 2001 at 01:32:37PM -0500, John David Anglin wrote:
> Should get_last_value not call gen_lowpart_for_combine when the
> last value is VOIDmode or does gen_lowpart_for_combine need fixing
> so it doesn't call simplify_gen_subreg with innermode=VOIDmode?

The only VOIDmode that gen_lowpart expects to handle is CONST_INT.
We almost certainly shouldn't have recorded a get_last_value for
a call insn; it's not useful.


r~

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

* Re: Question about SUBREG handling in get_last_value
  2001-11-19  9:14 ` Richard Henderson
@ 2001-11-19 14:38   ` John David Anglin
  2001-11-19 14:53     ` Richard Henderson
  2001-11-27 16:10     ` John David Anglin
  2001-11-27 13:56   ` Richard Henderson
  1 sibling, 2 replies; 12+ messages in thread
From: John David Anglin @ 2001-11-19 14:38 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc

> On Tue, Nov 27, 2001 at 01:32:37PM -0500, John David Anglin wrote:
> > Should get_last_value not call gen_lowpart_for_combine when the
> > last value is VOIDmode or does gen_lowpart_for_combine need fixing
> > so it doesn't call simplify_gen_subreg with innermode=VOIDmode?
> 
> The only VOIDmode that gen_lowpart expects to handle is CONST_INT.
> We almost certainly shouldn't have recorded a get_last_value for
> a call insn; it's not useful.

This wss my initial attempt to fix the problem:

2001-11-27  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* combine.c (gen_lowpart_for_combine): Don't call simplify_gen_subreg
	with a VOIDmode inner mode.

--- combine.c	Mon Nov 26 17:34:26 2001
+++ combine.c.new	Tue Nov 27 13:40:35 2001
@@ -9739,7 +9739,7 @@
   /* If we couldn't simplify X any other way, just enclose it in a
      SUBREG.  Normally, this SUBREG won't match, but some patterns may
      include an explicit SUBREG or we may simplify it further in combine.  */
-  else
+  else if (GET_MODE (x) != VOIDmode)
     {
       int offset = 0;
       rtx res;
@@ -9748,8 +9748,10 @@
       res = simplify_gen_subreg (mode, x, GET_MODE (x), offset);
       if (res)
 	return res;
-      return gen_rtx_CLOBBER (GET_MODE (x), const0_rtx);
+      return gen_rtx_CLOBBER (mode, const0_rtx);
     }
+  else
+    return gen_rtx_CLOBBER (mode, const0_rtx);
 }
 \f
 /* These routines make binary and unary operations by first seeing if they

It sound like you would prefer a solution which doesn't record values
which aren't useful.  I presume some mod is needed to get_last_value_validate.
However, how to decide what is useful and what isn't?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: Question about SUBREG handling in get_last_value
  2001-11-19 14:38   ` John David Anglin
@ 2001-11-19 14:53     ` Richard Henderson
  2001-11-20  4:57       ` John David Anglin
  2001-11-27 16:21       ` Richard Henderson
  2001-11-27 16:10     ` John David Anglin
  1 sibling, 2 replies; 12+ messages in thread
From: Richard Henderson @ 2001-11-19 14:53 UTC (permalink / raw)
  To: John David Anglin; +Cc: gcc

On Tue, Nov 27, 2001 at 07:10:35PM -0500, John David Anglin wrote:
> 	* combine.c (gen_lowpart_for_combine): Don't call simplify_gen_subreg
> 	with a VOIDmode inner mode.

This, however, doesn't special-case CONST_INT.

> However, how to decide what is useful and what isn't?

Well, I can tell you that a CALL isn't.


r~

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

* Re: Question about SUBREG handling in get_last_value
  2001-11-19 14:53     ` Richard Henderson
@ 2001-11-20  4:57       ` John David Anglin
  2001-11-27 18:14         ` John David Anglin
  2001-11-27 16:21       ` Richard Henderson
  1 sibling, 1 reply; 12+ messages in thread
From: John David Anglin @ 2001-11-20  4:57 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc

> On Tue, Nov 27, 2001 at 07:10:35PM -0500, John David Anglin wrote:
> > 	* combine.c (gen_lowpart_for_combine): Don't call simplify_gen_subreg
> > 	with a VOIDmode inner mode.
> 
> This, however, doesn't special-case CONST_INT.

That's because simplify_gen_subreg and for that matter simplify_subreg
abort unconditionally when innermode is VOIDmode.  I don't see how
simplify_gen_subreg can handle a CONST_INT if it doesn't know its mode.

I have another situation where simplify_subreg is called with a
VOIDmode innermode.  In that case, innermode probably should be
DImode (the mode of the register into which the CONST_INT was
substituted).  This can happen in simplify_if_then_else.  The function
known_cond can return can return a rtx with mode VOIDmode.  The simple
solution was to have known_cond return X if the modes of X and REG
differ.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: Question about SUBREG handling in get_last_value
  2001-11-19  3:26 Question about SUBREG handling in get_last_value John David Anglin
  2001-11-19  9:14 ` Richard Henderson
@ 2001-11-20 16:13 ` Jan Hubicka
  2001-11-28  1:12   ` Jan Hubicka
  2001-11-27 10:32 ` John David Anglin
  2 siblings, 1 reply; 12+ messages in thread
From: Jan Hubicka @ 2001-11-20 16:13 UTC (permalink / raw)
  To: John David Anglin; +Cc: gcc

> In looking at the testresults for hppa64-hp-hpux11.00, there are a few
> FAILs due to aborts in simplify_gen_subreg when it is called with
> innermode==VOIDmode.  This happens for example in compile/20000420-2.c
> at -O1.
> 
> The problem arises with this situation in get_last_value:
> 
> (gdb) p debug_rtx (x)
> 
> (subreg:SI (reg:DI 28 %r28) 4)
> 
> (gdb) p debug_rtx (reg_last_set_value[28])
> 
> (call (clobber:SI (const_int 0 [0x0]))
>     (const_int 64 [0x40]))
> 
> As can be seen, the last value is VOIDmode and the attempt to
> simplify it in gen_lowpart_for_combine leads to the abort.  It
> looks like `clobber:SI (const_int 0 [0x0])' might have been
> substituted before the call to last value where the abort
> occurs.
> 
> Should get_last_value not call gen_lowpart_for_combine when the
> last value is VOIDmode or does gen_lowpart_for_combine need fixing
> so it doesn't call simplify_gen_subreg with innermode=VOIDmode?

I guess the proper fix is to simplify the subreg while doing the
replacement and thats what should happen in the subst function.

Do you know where exactly the value is replaced and why the mode
is lost?  See how combine_simplify_rtx keep the original mode
before substitution so the simplify_subreg is happy.

Honza
> 
> Dave
> -- 
> J. David Anglin                                  dave.anglin@nrc.ca
> National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Question about SUBREG handling in get_last_value
  2001-11-19  3:26 Question about SUBREG handling in get_last_value John David Anglin
  2001-11-19  9:14 ` Richard Henderson
  2001-11-20 16:13 ` Jan Hubicka
@ 2001-11-27 10:32 ` John David Anglin
  2 siblings, 0 replies; 12+ messages in thread
From: John David Anglin @ 2001-11-27 10:32 UTC (permalink / raw)
  To: gcc

In looking at the testresults for hppa64-hp-hpux11.00, there are a few
FAILs due to aborts in simplify_gen_subreg when it is called with
innermode==VOIDmode.  This happens for example in compile/20000420-2.c
at -O1.

The problem arises with this situation in get_last_value:

(gdb) p debug_rtx (x)

(subreg:SI (reg:DI 28 %r28) 4)

(gdb) p debug_rtx (reg_last_set_value[28])

(call (clobber:SI (const_int 0 [0x0]))
    (const_int 64 [0x40]))

As can be seen, the last value is VOIDmode and the attempt to
simplify it in gen_lowpart_for_combine leads to the abort.  It
looks like `clobber:SI (const_int 0 [0x0])' might have been
substituted before the call to last value where the abort
occurs.

Should get_last_value not call gen_lowpart_for_combine when the
last value is VOIDmode or does gen_lowpart_for_combine need fixing
so it doesn't call simplify_gen_subreg with innermode=VOIDmode?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: Question about SUBREG handling in get_last_value
  2001-11-19  9:14 ` Richard Henderson
  2001-11-19 14:38   ` John David Anglin
@ 2001-11-27 13:56   ` Richard Henderson
  1 sibling, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2001-11-27 13:56 UTC (permalink / raw)
  To: John David Anglin; +Cc: gcc

On Tue, Nov 27, 2001 at 01:32:37PM -0500, John David Anglin wrote:
> Should get_last_value not call gen_lowpart_for_combine when the
> last value is VOIDmode or does gen_lowpart_for_combine need fixing
> so it doesn't call simplify_gen_subreg with innermode=VOIDmode?

The only VOIDmode that gen_lowpart expects to handle is CONST_INT.
We almost certainly shouldn't have recorded a get_last_value for
a call insn; it's not useful.


r~

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

* Re: Question about SUBREG handling in get_last_value
  2001-11-19 14:38   ` John David Anglin
  2001-11-19 14:53     ` Richard Henderson
@ 2001-11-27 16:10     ` John David Anglin
  1 sibling, 0 replies; 12+ messages in thread
From: John David Anglin @ 2001-11-27 16:10 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc

> On Tue, Nov 27, 2001 at 01:32:37PM -0500, John David Anglin wrote:
> > Should get_last_value not call gen_lowpart_for_combine when the
> > last value is VOIDmode or does gen_lowpart_for_combine need fixing
> > so it doesn't call simplify_gen_subreg with innermode=VOIDmode?
> 
> The only VOIDmode that gen_lowpart expects to handle is CONST_INT.
> We almost certainly shouldn't have recorded a get_last_value for
> a call insn; it's not useful.

This wss my initial attempt to fix the problem:

2001-11-27  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* combine.c (gen_lowpart_for_combine): Don't call simplify_gen_subreg
	with a VOIDmode inner mode.

--- combine.c	Mon Nov 26 17:34:26 2001
+++ combine.c.new	Tue Nov 27 13:40:35 2001
@@ -9739,7 +9739,7 @@
   /* If we couldn't simplify X any other way, just enclose it in a
      SUBREG.  Normally, this SUBREG won't match, but some patterns may
      include an explicit SUBREG or we may simplify it further in combine.  */
-  else
+  else if (GET_MODE (x) != VOIDmode)
     {
       int offset = 0;
       rtx res;
@@ -9748,8 +9748,10 @@
       res = simplify_gen_subreg (mode, x, GET_MODE (x), offset);
       if (res)
 	return res;
-      return gen_rtx_CLOBBER (GET_MODE (x), const0_rtx);
+      return gen_rtx_CLOBBER (mode, const0_rtx);
     }
+  else
+    return gen_rtx_CLOBBER (mode, const0_rtx);
 }
 \f
 /* These routines make binary and unary operations by first seeing if they

It sound like you would prefer a solution which doesn't record values
which aren't useful.  I presume some mod is needed to get_last_value_validate.
However, how to decide what is useful and what isn't?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: Question about SUBREG handling in get_last_value
  2001-11-19 14:53     ` Richard Henderson
  2001-11-20  4:57       ` John David Anglin
@ 2001-11-27 16:21       ` Richard Henderson
  1 sibling, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2001-11-27 16:21 UTC (permalink / raw)
  To: John David Anglin; +Cc: gcc

On Tue, Nov 27, 2001 at 07:10:35PM -0500, John David Anglin wrote:
> 	* combine.c (gen_lowpart_for_combine): Don't call simplify_gen_subreg
> 	with a VOIDmode inner mode.

This, however, doesn't special-case CONST_INT.

> However, how to decide what is useful and what isn't?

Well, I can tell you that a CALL isn't.


r~

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

* Re: Question about SUBREG handling in get_last_value
  2001-11-20  4:57       ` John David Anglin
@ 2001-11-27 18:14         ` John David Anglin
  0 siblings, 0 replies; 12+ messages in thread
From: John David Anglin @ 2001-11-27 18:14 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc

> On Tue, Nov 27, 2001 at 07:10:35PM -0500, John David Anglin wrote:
> > 	* combine.c (gen_lowpart_for_combine): Don't call simplify_gen_subreg
> > 	with a VOIDmode inner mode.
> 
> This, however, doesn't special-case CONST_INT.

That's because simplify_gen_subreg and for that matter simplify_subreg
abort unconditionally when innermode is VOIDmode.  I don't see how
simplify_gen_subreg can handle a CONST_INT if it doesn't know its mode.

I have another situation where simplify_subreg is called with a
VOIDmode innermode.  In that case, innermode probably should be
DImode (the mode of the register into which the CONST_INT was
substituted).  This can happen in simplify_if_then_else.  The function
known_cond can return can return a rtx with mode VOIDmode.  The simple
solution was to have known_cond return X if the modes of X and REG
differ.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

* Re: Question about SUBREG handling in get_last_value
  2001-11-20 16:13 ` Jan Hubicka
@ 2001-11-28  1:12   ` Jan Hubicka
  0 siblings, 0 replies; 12+ messages in thread
From: Jan Hubicka @ 2001-11-28  1:12 UTC (permalink / raw)
  To: John David Anglin; +Cc: gcc

> In looking at the testresults for hppa64-hp-hpux11.00, there are a few
> FAILs due to aborts in simplify_gen_subreg when it is called with
> innermode==VOIDmode.  This happens for example in compile/20000420-2.c
> at -O1.
> 
> The problem arises with this situation in get_last_value:
> 
> (gdb) p debug_rtx (x)
> 
> (subreg:SI (reg:DI 28 %r28) 4)
> 
> (gdb) p debug_rtx (reg_last_set_value[28])
> 
> (call (clobber:SI (const_int 0 [0x0]))
>     (const_int 64 [0x40]))
> 
> As can be seen, the last value is VOIDmode and the attempt to
> simplify it in gen_lowpart_for_combine leads to the abort.  It
> looks like `clobber:SI (const_int 0 [0x0])' might have been
> substituted before the call to last value where the abort
> occurs.
> 
> Should get_last_value not call gen_lowpart_for_combine when the
> last value is VOIDmode or does gen_lowpart_for_combine need fixing
> so it doesn't call simplify_gen_subreg with innermode=VOIDmode?

I guess the proper fix is to simplify the subreg while doing the
replacement and thats what should happen in the subst function.

Do you know where exactly the value is replaced and why the mode
is lost?  See how combine_simplify_rtx keep the original mode
before substitution so the simplify_subreg is happy.

Honza
> 
> Dave
> -- 
> J. David Anglin                                  dave.anglin@nrc.ca
> National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

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

end of thread, other threads:[~2001-11-28  9:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-19  3:26 Question about SUBREG handling in get_last_value John David Anglin
2001-11-19  9:14 ` Richard Henderson
2001-11-19 14:38   ` John David Anglin
2001-11-19 14:53     ` Richard Henderson
2001-11-20  4:57       ` John David Anglin
2001-11-27 18:14         ` John David Anglin
2001-11-27 16:21       ` Richard Henderson
2001-11-27 16:10     ` John David Anglin
2001-11-27 13:56   ` Richard Henderson
2001-11-20 16:13 ` Jan Hubicka
2001-11-28  1:12   ` Jan Hubicka
2001-11-27 10:32 ` John David Anglin

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