[Bug rtl-optimization/48580] missed optimization: integer overflow checks
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Tue Apr 12 21:16:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48580
--- Comment #7 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-04-12 21:16:41 UTC ---
On Tue, 12 Apr 2011, zackw at panix dot com wrote:
> Addendum: what would *you* describe as the correct C idiom for
> ensuring that the product of two signed integers was positive and did
> not overflow the range of a same-sized signed integer, assuming
> nothing about either multiplicand?
I think that's bordering complicated enough that any two people are likely
to produce different enough code that it may not be worth detecting - the
cases where generic C becomes complicated like that are the ones providing
the best case for built-in operations where you can just say "multiply two
(signed) values, check whether the result fits in 31-bit unsigned and set
an overflow flag accordingly".
More information about the Gcc-bugs
mailing list