public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "steven at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/56309] -O3 optimizer generates conditional moves instead of compare and branch resulting in almost 2x slower code
Date: Thu, 14 Feb 2013 17:10:00 -0000	[thread overview]
Message-ID: <bug-56309-4-DUSLWf5IZi@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56309-4@http.gcc.gnu.org/bugzilla/>


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

--- Comment #12 from Steven Bosscher <steven at gcc dot gnu.org> 2013-02-14 17:10:02 UTC ---
A bit more clear with insn 195 added:

  195: flags:CC=cmp(r124:DI,r235:DI)
  197: r116:DI={(gtu(flags:CC,0))?r125:DI:r233:DI}
  199: {r110:DI=r110:DI+0x1;clobber flags:CC;}
  201: flags:CC=cmp(r124:DI,r235:DI)
  202: r221:DI={(gtu(flags:CC,0))?r126:DI:r124:DI}

insns 195 and 201 compute the same condition but GCC can't eliminate
the comparison in insns 201 because insn 199 clobbers the flags (i.e.
destroys the result from insn 195).

As for speed, of course I can measure that myself:

--- by-val-O3.s.orig    2013-02-14 18:06:56.000000000 +0100
+++ by-val-O3.s 2013-02-14 18:07:23.000000000 +0100
@@ -357,9 +357,8 @@
        shrq    $32, %rdi
        cmpq    %r8, %rdx
        cmovbe  %r11, %rdi
-       addq    $1, %rax
-       cmpq    %r8, %rdx
        cmovbe  %rdx, %rcx
+       addq    $1, %rax
        cmpq    %rbp, %rax
        movq    %rcx, -8(%rsi,%rax,8)
        jne     .L50

unmodified: Took 14.31 seconds total.
modified:   Took 13.04 seconds total.

So re. comment #9: it's not the problem but it'd be a small improvement.


  parent reply	other threads:[~2013-02-14 17:10 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-13 20:21 [Bug middle-end/56309] New: " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-56309-4-DUSLWf5IZi@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).