This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/46680] Suboptimal code generated for bool comparisons
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 27 Nov 2010 14:59:29 +0000
- Subject: [Bug c++/46680] Suboptimal code generated for bool comparisons
- Auto-submitted: auto-generated
- References: <bug-46680-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46680
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|INVALID |WONTFIX
--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-11-27 14:59:21 UTC ---
(In reply to comment #2)
> >> Am I missing something?
>
> > -O1 / -O2 / -O3 / -Os option.
>
> I know about these optimization flags :).
> My suggestion is directed specifically to -O0.
>
> I would not rest knowing that it generates 4 instructions per comparison, while
> it could use 2 instructions, reducing my code size and my compilation time
> while using -O0, which is the default one.
GCC is known to generate very bad code at -O0, but this is expected.
The reason is that GCC makes sure !value is computed into a register
(for the sake of debugging), thus does
temp = !value;
if (temp)
...