public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/56309] New: -O3 optimizer generates conditional moves instead of compare and branch resulting in almost 2x slower code
@ 2013-02-13 20:21 arturomdn at gmail dot com
  2013-02-13 20:23 ` [Bug middle-end/56309] " arturomdn at gmail dot com
                   ` (32 more replies)
  0 siblings, 33 replies; 34+ messages in thread
From: arturomdn at gmail dot com @ 2013-02-13 20:21 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56309
           Summary: -O3 optimizer generates conditional moves instead of
                    compare and branch resulting in almost 2x slower code
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: arturomdn@gmail.com


Created attachment 29442
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29442
Self contained source file with parameter x passed by value (slow)

This bug report reflects the analysis of a question asked in stackoverflow

http://stackoverflow.com/questions/14805641/why-does-changing-const-ull-to-const-ull-in-function-parameter-result-in-pe/14819939#14819939

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.

Two files are attached

by-val-O3.ii
by-ref-O3.ii

They differ only in the way the unsigned long long parameter "x" is passed.

./by-ref-O3
Took 11.85 seconds total.

./by-ref-O3
Took 6.67 seconds total.


^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2021-09-04 20:26 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-13 20:21 [Bug middle-end/56309] New: -O3 optimizer generates conditional moves instead of compare and branch resulting in almost 2x slower code arturomdn at gmail dot com
2013-02-13 20:23 ` [Bug middle-end/56309] " arturomdn at gmail dot com
2013-02-13 20:26 ` [Bug target/56309] " pinskia at gcc dot gnu.org
2013-02-13 20:29 ` arturomdn at gmail dot com
2013-02-14  8:16 ` ubizjak at gmail dot com
2013-02-14  8:22 ` ubizjak at gmail dot com
2013-02-14  8:28 ` ubizjak at gmail dot com
2013-02-14 14:49 ` ysrumyan at gmail dot com
2013-02-14 15:53 ` arturomdn at gmail dot com
2013-02-14 16:01 ` arturomdn at gmail dot com
2013-02-14 16:44 ` arturomdn at gmail dot com
2013-02-14 16:59 ` steven at gcc dot gnu.org
2013-02-14 17:10 ` steven at gcc dot gnu.org
2013-02-14 17:26 ` [Bug tree-optimization/56309] " steven at gcc dot gnu.org
2013-02-14 17:31 ` arturomdn at gmail dot com
2013-02-14 17:34 ` ubizjak at gmail dot com
2013-02-14 17:43 ` arturomdn at gmail dot com
2013-02-14 17:50 ` ubizjak at gmail dot com
2013-02-14 18:23 ` ubizjak at gmail dot com
2013-02-14 18:35 ` [Bug target/56309] " ubizjak at gmail dot com
2013-02-14 22:18 ` steven at gcc dot gnu.org
2013-02-15  6:50 ` izamyatin at gmail dot com
2013-02-15  7:15 ` jakub at gcc dot gnu.org
2013-02-15  9:33 ` rguenth at gcc dot gnu.org
2013-02-15  9:36 ` rguenth at gcc dot gnu.org
2013-02-17  8:35 ` [Bug target/56309] conditional moves instead of compare and branch result " ubizjak at gmail dot com
2013-02-17  8:38 ` ubizjak at gmail dot com
2013-02-17 10:10 ` ubizjak at gmail dot com
2013-09-22  6:37 ` icegood1980 at gmail dot com
2013-10-18  9:12 ` jakub at gcc dot gnu.org
2013-10-18 10:06 ` ubizjak at gmail dot com
2015-08-06  9:35 ` ysrumyan at gmail dot com
2021-09-04 20:24 ` peter at cordes dot ca
2021-09-04 20:26 ` peter at cordes dot ca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).