divide 64-bit by constant for 32-bit target machines

Richard Henderson rth@redhat.com
Tue May 22 15:46:00 GMT 2012


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~



More information about the Gcc-patches mailing list