This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix wide-int multiplication (PR tree-optimization/65170)
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Mike Stump <mikestump at comcast dot net>, Richard Biener <rguenther at suse dot de>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 23 Feb 2015 21:51:32 +0000
- Subject: Re: [PATCH] Fix wide-int multiplication (PR tree-optimization/65170)
- Authentication-results: sourceware.org; auth=none
- References: <20150223210012 dot GL1746 at tucnak dot redhat dot com>
Jakub Jelinek <jakub@redhat.com> writes:
> Hi!
>
> To represent 128-bit unsigned multiplication results of 64-bit unsigned
> operands one sometimes needs 3 HWIs instead of 2.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
> ok for trunk?
>
> 2015-02-23 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/65170
> * wide-int.cc (wi::mul_internal): For the umul_ppmm optimization,
> if val[1] < 0, clear also val[2] and return 3.
>
> * gcc.c-torture/execute/pr65170.c: New test.
> * gcc.dg/tree-ssa/vrp96.c: New test.
>
> --- gcc/wide-int.cc.jj 2015-01-27 09:25:38.000000000 +0100
> +++ gcc/wide-int.cc 2015-02-23 15:43:20.303280261 +0100
> @@ -1297,6 +1297,11 @@ wi::mul_internal (HOST_WIDE_INT *val, co
> return 1;
> }
> umul_ppmm (val[1], val[0], op1.ulow (), op2.ulow ());
> + if (val[1] < 0)
> + {
> + val[2] = 0;
> + return 3;
> + }
Think this needs to check "prec > HOST_BITS_PER_WIDE_INT * 2",
otherwise val[2] isn't relevant and might not exist.
Lookd good to me with that change, thanks.
Richard