public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [wide-int] Another tweak to convert_modes
@ 2013-11-02 10:48 Richard Sandiford
  2013-11-02 13:50 ` Kenneth Zadeck
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2013-11-02 10:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: zadeck, mikestump

It turns out that when doing a vector shift by 2, the optab routine
passes (const_int 2) to convert_modes with oldmode set to the mode
of the shift (e.g. something like V8HI).  When the target mode is a
real integer mode like SImode, mainline just ignores that oldmode
and returns a (const_int 2) regardless, but wide-int doesn't.

Saying that (const_int 2) has a vector mode is almost certainly a bug
that ought to be trapped by an assert, but we're not trying to fight
that battle here.  The current code:

  if (CONST_SCALAR_INT_P (x) 
      && GET_MODE_CLASS (mode) == MODE_INT
      && (oldmode == VOIDmode || GET_MODE_CLASS (oldmode) == MODE_INT))

is already coping with bogus oldmodes, just not in the way that
other routines seem to expect.

Tested on powerpc64-linux-gnu and x86_64-linux-gnu.  This fixed several
testsuite changes on the ARM targets.  OK to install?

Thanks,
Richard


Index: gcc/expr.c
===================================================================
--- gcc/expr.c	2013-11-02 10:34:44.083635650 +0000
+++ gcc/expr.c	2013-11-02 10:42:55.179233840 +0000
@@ -712,13 +712,12 @@ convert_modes (enum machine_mode mode, e
     return x;
 
   if (CONST_SCALAR_INT_P (x) 
-      && GET_MODE_CLASS (mode) == MODE_INT
-      && (oldmode == VOIDmode || GET_MODE_CLASS (oldmode) == MODE_INT))
+      && GET_MODE_CLASS (mode) == MODE_INT)
     {
       /* If the caller did not tell us the old mode, then there is
 	 not much to do with respect to canonization.  We have to assume
 	 that all the bits are significant.  */
-      if (oldmode == VOIDmode)
+      if (GET_MODE_CLASS (oldmode) != MODE_INT)
 	oldmode = MAX_MODE_INT;
       wide_int w = wide_int::from (std::make_pair (x, oldmode),
 				   GET_MODE_PRECISION (mode),

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

* Re: [wide-int] Another tweak to convert_modes
  2013-11-02 10:48 [wide-int] Another tweak to convert_modes Richard Sandiford
@ 2013-11-02 13:50 ` Kenneth Zadeck
  0 siblings, 0 replies; 2+ messages in thread
From: Kenneth Zadeck @ 2013-11-02 13:50 UTC (permalink / raw)
  To: gcc-patches, mikestump, rdsandiford

On 11/02/2013 06:48 AM, Richard Sandiford wrote:
> It turns out that when doing a vector shift by 2, the optab routine
> passes (const_int 2) to convert_modes with oldmode set to the mode
> of the shift (e.g. something like V8HI).  When the target mode is a
> real integer mode like SImode, mainline just ignores that oldmode
> and returns a (const_int 2) regardless, but wide-int doesn't.
>
> Saying that (const_int 2) has a vector mode is almost certainly a bug
> that ought to be trapped by an assert, but we're not trying to fight
> that battle here.  The current code:
>
>    if (CONST_SCALAR_INT_P (x)
>        && GET_MODE_CLASS (mode) == MODE_INT
>        && (oldmode == VOIDmode || GET_MODE_CLASS (oldmode) == MODE_INT))
>
> is already coping with bogus oldmodes, just not in the way that
> other routines seem to expect.
>
> Tested on powerpc64-linux-gnu and x86_64-linux-gnu.  This fixed several
> testsuite changes on the ARM targets.  OK to install?
>
> Thanks,
> Richard
or we can fix it on trunk and pull the patch up.    If you as an 
(former) rtl maintainer want to go in this direction, then fine.
>
> Index: gcc/expr.c
> ===================================================================
> --- gcc/expr.c	2013-11-02 10:34:44.083635650 +0000
> +++ gcc/expr.c	2013-11-02 10:42:55.179233840 +0000
> @@ -712,13 +712,12 @@ convert_modes (enum machine_mode mode, e
>       return x;
>   
>     if (CONST_SCALAR_INT_P (x)
> -      && GET_MODE_CLASS (mode) == MODE_INT
> -      && (oldmode == VOIDmode || GET_MODE_CLASS (oldmode) == MODE_INT))
> +      && GET_MODE_CLASS (mode) == MODE_INT)
>       {
>         /* If the caller did not tell us the old mode, then there is
>   	 not much to do with respect to canonization.  We have to assume
>   	 that all the bits are significant.  */
> -      if (oldmode == VOIDmode)
> +      if (GET_MODE_CLASS (oldmode) != MODE_INT)
>   	oldmode = MAX_MODE_INT;
>         wide_int w = wide_int::from (std::make_pair (x, oldmode),
>   				   GET_MODE_PRECISION (mode),

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

end of thread, other threads:[~2013-11-02 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-02 10:48 [wide-int] Another tweak to convert_modes Richard Sandiford
2013-11-02 13:50 ` Kenneth Zadeck

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