This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: divide 64-bit by constant for 32-bit target machines
- From: Richard Henderson <rth at redhat dot com>
- To: Dinar Temirbulatov <dtemirbulatov at gmail dot com>
- Cc: Richard Earnshaw <rearnsha at arm dot com>, Michael Hope <michael dot hope at linaro dot org>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "aph at redhat dot com" <aph at redhat dot com>, Alexey Kravets <mr dot kayrick at gmail dot com>
- Date: Tue, 22 May 2012 08:45:19 -0700
- Subject: Re: divide 64-bit by constant for 32-bit target machines
- References: <CAMnfPmPi9U9E=ntqYx1vdsC3E+6XZ7isTk4vdXLDD02xT_n-4g@mail.gmail.com> <CANLjY-mOtYW54RQuQVxGdiS_BB4WTYbDp5RhfAEgTu-gTKKc+A@mail.gmail.com> <CAMnfPmP9jN7W_P9AmHzSW-Ao+eoBVTe6KKVKbw+eYRcmQyUYrQ@mail.gmail.com> <4FA28ACB.5010404@arm.com> <CAMnfPmOjuh6mSaYEbxFfrYz6qus3Lv_=k2gYicoB-atkK3-O9w@mail.gmail.com>
On 05/22/12 07:05, Dinar Temirbulatov wrote:
> + if ((size - 1 > BITS_PER_WORD
> + && BITS_PER_WORD == 32 && mode == DImode)
Do note that this patch will not go in with hard-coded
SImode and DImode references.
Which, really, you do not even need.
&& GET_MODE_BITSIZE (mode) == 2*BITS_PER_WORD
is what you wanted for testing for double-word-ness,
and word_mode is a good substitute for SImode here.
+ /* Splitting the 64-bit constant for the higher and the lower parts. */
+ y0 = gen_rtx_CONST_INT (DImode, d&UINT32_MAX);
+ y1 = gen_rtx_CONST_INT (DImode, d>>32);
Use gen_int_mode.
> + x1 = convert_to_mode (DImode, x1, 1);
> + x0 = convert_to_mode (DImode, x0, 1);
> +
> + /* Splitting the 64-bit constant for the higher and the lower parts. */
> + y0 = gen_rtx_CONST_INT (DImode, d&UINT32_MAX);
> + y1 = gen_rtx_CONST_INT (DImode, d>>32);
> +
> + z2 = gen_reg_rtx (DImode);
> + u0 = gen_reg_rtx (DImode);
> +
> + /* Unsigned multiplication of the higher multiplier part
> + and the higher constant part. */
> + z2 = expand_mult(DImode, x1, y1, z2, 1);
> + /* Unsigned multiplication of the lower multiplier part
> + and the higher constant part. */
> + u0 = expand_mult(DImode, x0, y1, u0, 1);
I'm fairly sure you really want to be using expand_widening_mult
here, rather than using convert_to_mode first. While combine may
be able to re-generate a widening multiply out of this sequence,
there's no sense making it work too hard.
r~