On Mon, Jan 16, 2017 at 02:42:08PM +0800, Kito Cheng wrote:
> 2017-01-16  Kito Cheng <kito.ch...@gmail.com>
>             Kuan-Lin Chen <kuanlinche...@gmail.com>
> 
>         PR target/PR79079
>         * gcc/internal-fn.c (expand_mul_overflow): Use convert_modes instead 
> of
>         gen_lowpart.

No gcc/ prefix in gcc/ChangeLog.

> @@ -1505,11 +1505,12 @@ expand_mul_overflow (location_t loc, tree lhs, tree 
> arg0, tree arg1,
>            if (loxhi >> (bitsize / 2) == 0             (if uns).  */
>         rtx hipartloxhi = expand_shift (RSHIFT_EXPR, mode, loxhi, hprec,
>                                         NULL_RTX, 0);
> -       hipartloxhi = gen_lowpart (hmode, hipartloxhi);
> +       hipartloxhi = convert_modes (hmode, mode, hipartloxhi, uns);

While I think convert_modes on truncation should ignore the last argument,
given that the corresponding expand_shift uses ins of 0, I think
convert_modes should use 0 here too (the earlier convert_modes calls you've
added are fine).

>         rtx signbitloxhi = const0_rtx;
>         if (!uns)
>           signbitloxhi = expand_shift (RSHIFT_EXPR, hmode,
> -                                      gen_lowpart (hmode, loxhi),
> +                                      convert_modes (hmode, mode,
> +                                                     loxhi, uns),

And here 0 as well (it is guarded by if (!uns) anyway, and it is what
expand_shift will use too).

>                                        hprec - 1, NULL_RTX, 0);
>  
>         do_compare_rtx_and_jump (signbitloxhi, hipartloxhi, NE, true, hmode,
> @@ -1519,7 +1520,8 @@ expand_mul_overflow (location_t loc, tree lhs, tree 
> arg0, tree arg1,
>         /* res = (loxhi << (bitsize / 2)) | (hmode) lo0xlo1;  */
>         rtx loxhishifted = expand_shift (LSHIFT_EXPR, mode, loxhi, hprec,
>                                          NULL_RTX, 1);
> -       tem = convert_modes (mode, hmode, gen_lowpart (hmode, lo0xlo1), 1);
> +       tem = convert_modes (mode, hmode,
> +                            convert_modes (hmode, mode, lo0xlo1, uns), 1);

And here 1.

Ok for trunk with those changes.

        Jakub

Reply via email to