This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC [1/2] divmod transform
- From: Richard Biener <rguenther at suse dot de>
- To: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, gcc Patches <gcc-patches at gcc dot gnu dot org>, Ramana Radhakrishnan <ramana dot radhakrishnan at arm dot com>, Kugan Vivekanandarajah <kugan dot vivekanandarajah at linaro dot org>, Jim Wilson <jim dot wilson at linaro dot org>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Mon, 30 May 2016 09:45:13 +0200 (CEST)
- Subject: Re: RFC [1/2] divmod transform
- Authentication-results: sourceware.org; auth=none
- References: <CAAgBjM=GrLmtmr7LpkzmTXFauoCuuAqJzYQK4ExxTV+xm4_qsg at mail dot gmail dot com> <CAFiYyc2JKhzqBj7AriX5yfdW9yVecn=B=9JpkcqNU9UTOK4Dyw at mail dot gmail dot com> <CAAgBjM=hEZb6BnTMDL7KQ=78xGZ4D8osWyXysBedfroVec7BWg at mail dot gmail dot com> <alpine dot LSU dot 2 dot 11 dot 1605241357590 dot 18037 at t29 dot fhfr dot qr> <CAAgBjMmvm+Ve_6hsWd31=h3ntLRfEvHJy=n+ck1r-j95TyNiqw at mail dot gmail dot com> <alpine dot LSU dot 2 dot 11 dot 1605241605250 dot 18037 at t29 dot fhfr dot qr> <CAAgBjMmmUphARUNQXXn5LdhcmQU_F4BmCgdD_juCgEU06_-L4A at mail dot gmail dot com> <alpine dot LSU dot 2 dot 11 dot 1605250922190 dot 13344 at t29 dot fhfr dot qr> <CAAgBjMmYA+dmittRANSb5g+_0GB+ifvNCzNHOcJrJ26cDh-o_Q at mail dot gmail dot com> <alpine dot LSU dot 2 dot 11 dot 1605271208040 dot 13344 at t29 dot fhfr dot qr> <CAAgBjM=Cq2PHFMD-W6XUTSA1PtTjMLDJL1W5gqnfjLLjZ7Z1xg at mail dot gmail dot com> <alpine dot LSU dot 2 dot 11 dot 1605271356480 dot 13344 at t29 dot fhfr dot qr> <CAAgBjM=tvq76zKQwUx1cb8kz37WJYV52RVA9P+Z7j7x3ekQjsw at mail dot gmail dot com>
On Mon, 30 May 2016, Prathamesh Kulkarni wrote:
> The attached patch ICE's during bootstrap for x86_64, and is reproducible with
> following case with -m32 -O2:
>
> typedef long long type;
>
> type f(type x, type y)
> {
> type q = x / y;
> type r = x % y;
> return q + r;
> }
>
> The ICE happens because the test-case hits
> gcc_assert (unsignedp);
> in default_expand_divmod_libfunc ().
That's of course your function (and ICE).
> Surprisingly, optab_libfunc (sdivmod_optab, DImode) returns optab_libfunc
> with name "__divmoddi4" although __divmoddi4() is nowhere defined in
> libgcc for x86.
> (I verified that by forcing the patch to generate call to __divmoddi4,
> which results in undefined reference to __divmoddi4).
>
> This happens because in optabs.def we have:
> OPTAB_NL(sdivmod_optab, "divmod$a4", UNKNOWN, "divmod", '4', gen_int_libfunc)
>
> and gen_int_libfunc generates "__divmoddi4" on first call to optab_libfunc
> and sets optab_libfunc (sdivmod_optab, DImode) to "__divmoddi4".
> I wonder if we should remove gen_int_libfunc entry in optabs.def for
> sdivmod_optab ?
Hum, not sure - you might want to look at expand_divmod (though that
always just computes one part of the result in the end).
Joseph - do you know sth about why there's not a full set of divmod
libfuncs in libgcc?
Thanks,
Richard.