public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "me at williamgrant dot id.au" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/64304] New: AArch64 miscompilation with -mgeneral-regs-only
Date: Sun, 14 Dec 2014 11:18:00 -0000	[thread overview]
Message-ID: <bug-64304-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64304

            Bug ID: 64304
           Summary: AArch64 miscompilation with -mgeneral-regs-only
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: me at williamgrant dot id.au

The aarch64 target, from 4.8.0 to today's master (tested up to 4b686186), drops
an "and x0, x0, #0x7" in some integer-only code when built with
-mgeneral-regs-only. Ignoring register assignment, the only change in the
resultant code is the missing and. It works fine without -mgeneral-regs-only
and on several other targets.

This test case is quite fragile. The original code didn't need -fno-inline to
reproduce it, and the problem disappeared in an earlier test with
-fno-tree-vrp. -fdump-rtl-all reveals that the adddi vanishes between ud_dce
and combine, but I can't see any significant differences in the input RTL to
explain that.

$ gcc -mgeneral-regs-only -O2 -fno-inline -o gen-test gen-test.c
$ ./gen-test && echo success || echo fail
fail
$ gcc -O2 -fno-inline -o gen-test gen-test.c
$ ./gen-test && echo success || echo fail
success

----
unsigned char byte = 0;

void set_bit(unsigned int bit, unsigned char value) {
    unsigned char mask = (unsigned char)(1 << (bit & 7));
    if (!value) {
        byte &= (unsigned char)~mask;
    } else {
        byte |= mask;
    }
}

int main(int argc, char **argv) {
    set_bit(8, 1);
    set_bit(9, 1);
    return byte != 3;
}
----


             reply	other threads:[~2014-12-14 11:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-14 11:18 me at williamgrant dot id.au [this message]
2014-12-15  3:27 ` [Bug target/64304] " kugan at gcc dot gnu.org
2015-01-06 18:23 ` [Bug rtl-optimization/64304] " jiwang at gcc dot gnu.org
2015-01-09 13:48 ` jiwang at gcc dot gnu.org
2015-01-09 21:46 ` [Bug target/64304] " pinskia at gcc dot gnu.org
2015-01-19 14:14 ` jiwang at gcc dot gnu.org
2015-01-19 14:16 ` jiwang at gcc dot gnu.org
2015-05-05 15:50 ` fyang at gcc dot gnu.org
2015-05-05 15:59 ` fyang at gcc dot gnu.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-64304-4@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).