[Bug target/56309] -O3 optimizer generates conditional moves instead of compare and branch resulting in almost 2x slower code

ysrumyan at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 14 14:49:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56309

Yuri Rumyantsev <ysrumyan at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ysrumyan at gmail dot com

--- Comment #7 from Yuri Rumyantsev <ysrumyan at gmail dot com> 2013-02-14 14:49:31 UTC ---
My 2 cents.

We can enhance if conversion phase in gcc by analyzing conditional jump
probablity and if we have skewed hammock do not perform transformation. In
general it requires to use profiling but for this specific example we can use
so called "static profiler", e.g. in our example we have 
    if (tmp >= imax) 
where imax = 1 << 32, i.e. huge conastant. For such conditions we can assume
that this branch is likely not-taken and reject if-conversion of such hammock.

Other possiblity is implement support for __builtin_expect in gcc but it
requires source code changing too.



More information about the Gcc-bugs mailing list