[PATCH] expand, v2: Fix up expand_doubleword_mod on 32-bit targets [PR98229]

Richard Biener rguenther@suse.de
Fri Dec 11 11:39:17 GMT 2020


On Fri, 11 Dec 2020, Jakub Jelinek wrote:

> On Fri, Dec 11, 2020 at 11:34:01AM +0100, Richard Biener wrote:
> > Shouldn't we simply use gen_int_mode?
> 
> You're right, that is shorter.  So like this?

Yes, OK.

> BTW, looking at gen_int_mode, wouldn't it be better to add an overload
> for HOST_WIDE_INT first argument so that it wouldn't need to go through
> poly_int?  Or would that then be ambiguous with int, unsigned etc.
> arguments?

Not sure but marshalling as poly-int64 should be cheap.

Richard.

> 2020-12-10  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR rtl-optimization/98229
> 	* optabs.c (expand_doubleword_mod): Canonicalize op1 and
> 	1 - INTVAL (op1) as word_mode constants when used in
> 	word_mode arithmetics.
> 
> 	* gcc.c-torture/compile/pr98229.c: New test.
> 
> --- gcc/optabs.c.jj	2020-12-11 00:30:41.892272376 +0100
> +++ gcc/optabs.c	2020-12-11 11:51:15.902855312 +0100
> @@ -1081,7 +1081,8 @@ expand_doubleword_mod (machine_mode mode
>  		return NULL_RTX;
>  	    }
>  	}
> -      rtx remainder = expand_divmod (1, TRUNC_MOD_EXPR, word_mode, sum, op1,
> +      rtx remainder = expand_divmod (1, TRUNC_MOD_EXPR, word_mode, sum,
> +				     gen_int_mode (INTVAL (op1), word_mode),
>  				     NULL_RTX, 1, OPTAB_DIRECT);
>        if (remainder == NULL_RTX)
>  	return NULL_RTX;
> @@ -1099,7 +1100,8 @@ expand_doubleword_mod (machine_mode mode
>  		return NULL_RTX;
>  	    }
>  	  mask = expand_simple_binop (word_mode, AND, mask,
> -				      GEN_INT (1 - INTVAL (op1)),
> +				      gen_int_mode (1 - INTVAL (op1),
> +						    word_mode),
>  				      NULL_RTX, 1, OPTAB_DIRECT);
>  	  if (mask == NULL_RTX)
>  	    return NULL_RTX;
> --- gcc/testsuite/gcc.c-torture/compile/pr98229.c.jj	2020-12-11 11:49:34.518993120 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr98229.c	2020-12-11 11:49:34.517993131 +0100
> @@ -0,0 +1,7 @@
> +/* PR rtl-optimization/98229 */
> +
> +unsigned long long
> +foo (unsigned long long x)
> +{
> +  return x % ~0U;
> +}
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)


More information about the Gcc-patches mailing list