This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/56598] New: Optimizer can't invert conditional when inlining a bool function
- From: "msharov at users dot sourceforge.net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 11 Mar 2013 17:44:16 +0000
- Subject: [Bug rtl-optimization/56598] New: Optimizer can't invert conditional when inlining a bool function
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56598
Bug #: 56598
Summary: Optimizer can't invert conditional when inlining a
bool function
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: msharov@users.sourceforge.net
Created attachment 29640
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29640
Simple test case and its asm
When a bool macro like #define X(i) (i==3) is replaced with a static inline
bool function, the optimizer sometimes generates tangled control flow. With
code blocks ABCD the jumps go A->C->B->D. If the macro is used, the compiler
can invert the conditional and emit ACBD with two fewer jmps. In the attached
test case, func1 has .L3-.L4 block that is jumped into, out of, and over.
Swapping the .L2-.L3 and .L3-.L4 blocks would produce the simpler control flow
in func2. The test case is compiled with -Os, on x86_64. -O2 and -O3 also
produce the same behavior, but require a larger test case to avoid path
unrolling. C++ compiler must be used. The same test case compiled as C produces
identical func1 and func2.