This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: question regarding div / std::div implementation
- From: Daniel Gutson <daniel dot gutson at tallertechnologies dot com>
- To: Paul Eggert <eggert at cs dot ucla dot edu>
- Cc: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 20 Apr 2016 19:18:23 -0300
- Subject: Re: question regarding div / std::div implementation
- Authentication-results: sourceware.org; auth=none
- References: <CAF5HaEXKZ7j-gbZPiWPhDpx7=R0zm1xYvXNYCNUMG4WeZS532Q at mail dot gmail dot com> <5717DF65 dot 5060606 at linaro dot org> <CAF5HaEWdpAGiXtCO36u3F0QGAXfVHL+qkY+RLsszpv7paPVdMg at mail dot gmail dot com> <5717E68D dot 2020905 at linaro dot org> <CAF5HaEWuSS7dEEM6ogU6TCqQ-Y7OM9DC1HFCeuuAGL0vKtL2Kw at mail dot gmail dot com> <5717EB44 dot 5020508 at linaro dot org> <CAF5HaEVWnU9_8Ae3gCR9Ns8sD_B8QoD794sp59XQNrqEw034EQ at mail dot gmail dot com> <5717F6BD dot 90705 at cs dot ucla dot edu> <CAF5HaEW-qiGwkpJCSHbptsMZzq--RJSOKoijx6qKiMRpXoYsvA at mail dot gmail dot com> <5717FE54 dot 3070003 at cs dot ucla dot edu>
On Wed, Apr 20, 2016 at 7:10 PM, Paul Eggert <eggert@cs.ucla.edu> wrote:
> On 04/20/2016 02:55 PM, Daniel Gutson wrote:
>>
>> That fools the compiler.
>
>
> Yes, bizarre C code can fool the compiler. I was talking about realistic
> code, not contrived examples.
No need to be bizarre (I just wanted to exaggerate). Code by not
knowledgeable programmers,
or simply programmers that don't know that such optimization exists
(that requires that both lines have to be written adjacent)
will miss the optimization.
>
> glibc itself uses % and / in places where div/ldiv/lldiv might plausibly be
> used internally, and this is portable and maintainable and efficient and
> there is no real reason to change this, even if div/ldiv/lldiv were tuned.
> Similarly for other C applications.
This discussion has already moved to the compiler arena. Once the
builtins are implemented,
you glibc maintainers may want to consider changing that in order to
use those functions, or not.
In any case, code already using the div/ldiv/lldiv functions will be
benefited, and that's already something good.
Thanks for your feedback.
Daniel.
--
Daniel F. Gutson
Engineering Manager
San Lorenzo 47, 3rd Floor, Office 5
CÃrdoba, Argentina
Phone: +54 351 4217888 / +54 351 4218211
Skype: dgutson
LinkedIn: http://ar.linkedin.com/in/danielgutson