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

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Feb 14 08:16:00 GMT 2013


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

Uros Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-02-14
                 CC|                            |hjl.tools at gmail dot com,
                   |                            |ubizjak at gmail dot com
     Ever Confirmed|0                           |1

--- Comment #4 from Uros Bizjak <ubizjak at gmail dot com> 2013-02-14 08:16:26 UTC ---
(In reply to comment #0)

> When an unsigned long long parameter to a function is passed by reference
> instead of by value the result is a dramatic almost 2x improvement in speed
> when compiled with -O3.  Given that the function is inlined this is unexpected.
>  Upon closer inspection it was found that the code generated is quite
> different, as if passing the parameter by value enables an optimization (use of
> x86 conditional moves) that backfires, possibly by suffering an unexpected
> stall in the processor.

This is due to x86 processor deficiency (HW bug?) with cmove insns. Please see
explanations in PR53346 and PR54073.

There is no solution (yet?), compiler should probably detect this situation and
avoid conversion to cmove.



More information about the Gcc-bugs mailing list