This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR79079 Fix __builtin_mul_overflow code gen for !TRULY_NOOP_TRUNCATION target
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Kito Cheng <kito dot cheng at gmail dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Kuan-Lin Chen <kuanlinchentw at gmail dot com>, matthew dot fortune at imgtec dot com, clm at codesourcery dot com, Andrew Waterman <andrew at sifive dot com>, Palmer Dabbelt <palmer at dabbelt dot com>
- Date: Mon, 16 Jan 2017 08:40:38 +0100
- Subject: Re: [PATCH] PR79079 Fix __builtin_mul_overflow code gen for !TRULY_NOOP_TRUNCATION target
- Authentication-results: sourceware.org; auth=none
- References: <CA+yXCZDNijzskL8f6MrDXA3RqdUNknE0meZzCEorkSAHuKHpsA@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Jan 16, 2017 at 02:42:08PM +0800, Kito Cheng wrote:
> 2017-01-16 Kito Cheng <kito.cheng@gmail.com>
> Kuan-Lin Chen <kuanlinchentw@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