public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "astrange at ithinksw dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/43233]  New: x86 flags not combined across blocks
Date: Tue, 02 Mar 2010 19:17:00 -0000	[thread overview]
Message-ID: <bug-43233-10175@http.gcc.gnu.org/bugzilla/> (raw)

Source:
int g1,g2,g3;

int f1(int a, int b)
{
    a &= 1;

    if (a) return g1;
    return g2;
}

int f2(int a, int b)
{
    a &= 1;

    if (b)
        g3++;

    if (a) return g1;
    return g2;
}

Compiled with:
> gcc -O3 -fomit-frame-pointer -S and_flags.c

f1 is ok but f2 generates this:
_f2:
        andl    $1, %edi <-- #1
        testl   %esi, %esi
        je      L7
        movq    _g3@GOTPCREL(%rip), %rax
        incl    (%rax)
L7:
        testl   %edi, %edi <-- #2
        jne     L10
        movq    _g2@GOTPCREL(%rip), %rax
        movl    (%rax), %eax
        ret
        .align 4,0x90
L10:
        movq    _g1@GOTPCREL(%rip), %rax
        movl    (%rax), %eax
        ret

The andl and testl should be folded into one andl.

Code is reduced from ffmpeg h264 decoder. It's easy to work around by
reordering source lines, so not too important.


-- 
           Summary: x86 flags not combined across blocks
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: astrange at ithinksw dot com
  GCC host triplet: x86_64-*-*


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


             reply	other threads:[~2010-03-02 19:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-02 19:17 astrange at ithinksw dot com [this message]
2010-05-13 23:33 ` [Bug target/43233] " steven at gcc dot gnu dot org

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-43233-10175@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).