This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/48580] missed optimization: integer overflow checks
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 12 Apr 2011 21:16:46 +0000
- Subject: [Bug rtl-optimization/48580] missed optimization: integer overflow checks
- Auto-submitted: auto-generated
- References: <bug-48580-4@http.gcc.gnu.org/bugzilla/>
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".