[PATCH v2.0] Use saturated arithmetic for overflow detection.
Paul Eggert
eggert@cs.ucla.edu
Fri Nov 1 17:19:00 GMT 2013
Thanks for looking into this.
I agree with earlier comments that we care about overall
performance not just the individual ops, that optimizing
for code size is probably best unless we get significant numbers
suggesting otherwise, and that it may be time to ask the GCC folks
for help with fast saturated arithmetic ops. Some other suggestions:
Stick with inline functions not macros, and use lower-case names since they're
functions.
If you like tuning this stuff you might want to look at
<http://locklessinc.com/articles/sat_arithmetic/>, which
shows how to do saturated arithmetic without jumps, both portably
and on x86-64; I don't know whether this will save code space, though.
More information about the Libc-alpha
mailing list