This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR82816: Widening multiplies of bitfields
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Sandiford <richard dot sandiford at linaro dot org>
- Date: Mon, 6 Nov 2017 12:53:16 +0100
- Subject: Re: PR82816: Widening multiplies of bitfields
- Authentication-results: sourceware.org; auth=none
- References: <87mv43qskm.fsf@linaro.org>
On Fri, Nov 3, 2017 at 4:40 PM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> In this PR we tried to create a widening multiply of two 3-bit numbers,
> but that isn't a widening multiply at the optab/rtl level, since both
> the input and output still have the same mode.
>
> We could trap this either in is_widening_mult_p or (as the patch does)
> in the routines that actually ask for an optab. The latter seemed
> more natural since is_widening_mult_p doesn't otherwise care about modes.
>
> Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64-linux-gnu.
> OK to install?
Hum. I _think_ we should go one step further and disallow
types that do not match their mode precision.
Anyway, patch is ok.
Thanks,
Richard.
> Richard
>
>
> 2017-11-03 Richard Sandiford <richard.sandiford@linaro.org>
> Alan Hayward <alan.hayward@arm.com>
> David Sherwood <david.sherwood@arm.com>
>
> gcc/
> PR tree-optimization/82816
> * tree-ssa-math-opts.c (convert_mult_to_widen): Return false
> if the modes of the two types are the same.
> (convert_plusminus_to_widen): Likewise.
>
> gcc/testsuite/
> * gcc.c-torture/compile/pr82816.c: New test.
>
> Index: gcc/tree-ssa-math-opts.c
> ===================================================================
> --- gcc/tree-ssa-math-opts.c 2017-11-01 12:29:40.203534002 +0000
> +++ gcc/tree-ssa-math-opts.c 2017-11-03 11:18:03.046411241 +0000
> @@ -3259,6 +3259,9 @@ convert_mult_to_widen (gimple *stmt, gim
>
> to_mode = SCALAR_INT_TYPE_MODE (type);
> from_mode = SCALAR_INT_TYPE_MODE (type1);
> + if (to_mode == from_mode)
> + return false;
> +
> from_unsigned1 = TYPE_UNSIGNED (type1);
> from_unsigned2 = TYPE_UNSIGNED (type2);
>
> @@ -3449,6 +3452,9 @@ convert_plusminus_to_widen (gimple_stmt_
>
> to_mode = SCALAR_TYPE_MODE (type);
> from_mode = SCALAR_TYPE_MODE (type1);
> + if (to_mode == from_mode)
> + return false;
> +
> from_unsigned1 = TYPE_UNSIGNED (type1);
> from_unsigned2 = TYPE_UNSIGNED (type2);
> optype = type1;
> Index: gcc/testsuite/gcc.c-torture/compile/pr82816.c
> ===================================================================
> --- /dev/null 2017-11-03 10:40:07.002381728 +0000
> +++ gcc/testsuite/gcc.c-torture/compile/pr82816.c 2017-11-03 11:18:03.045411265 +0000
> @@ -0,0 +1,12 @@
> +struct A
> +{
> + int b:3;
> +} d, e;
> +
> +int c;
> +
> +void f ()
> +{
> + char g = d.b * e.b;
> + c = g;
> +}