This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2.0] Use saturated arithmetic for overflow detection.
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: libc-alpha at sourceware dot org
- Date: Fri, 01 Nov 2013 10:19:25 -0700
- Subject: Re: [PATCH v2.0] Use saturated arithmetic for overflow detection.
- Authentication-results: sourceware.org; auth=none
- References: <20131030174502 dot GA18107 at domone dot podge> <Pine dot LNX dot 4 dot 64 dot 1310301749400 dot 22878 at digraph dot polyomino dot org dot uk> <20131030183318 dot GA18706 at domone dot podge> <20131101133126 dot GA2546 at domone dot podge>
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.