public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "su at cs dot ucdavis.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/58726] New: wrong code at -Os on x86_64-linux-gnu (affecting trunk/4.7/4.6, but not 4.8)
Date: Mon, 14 Oct 2013 18:38:00 -0000	[thread overview]
Message-ID: <bug-58726-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 58726
           Summary: wrong code at -Os on x86_64-linux-gnu (affecting
                    trunk/4.7/4.6, but not 4.8)
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk miscompiles the following code on x86_64-linux at -Os in
both 32-bit and 64-bit modes. 

This is a regression from 4.8.x. 

It also affects 4.6.x and 4.7.x. 

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror
--enable-checking=release --with-gmp=/usr/local/gcc-trunk
--with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk
--with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.9.0 20131014 (experimental) [trunk revision 203511] (GCC) 
$ 
$ gcc-trunk -O1 small.c; a.out
-9162
$ gcc-trunk -Os small.c; a.out
-32768
$ 
$ gcc-4.8 -Os small.c; a.out
-9162
$ 
$ gcc-4.7 -Os small.c; a.out
-32768
$ gcc-4.6 -Os small.c; a.out
-32768
$ 

------------------------------------


int printf (const char *, ...);

int a, c;

union
{
  int f1;
  int f2:1;
} b;

short
foo (short p)
{
  return p < 0 ? p : a;
}

int
main ()
{
  b.f1 = 56374;
  unsigned short d;
  int e = b.f2;
  d = e == 0 ? b.f1 : 0;
  c = foo (d);
  printf ("%d\n", c);
  return 0;
}


             reply	other threads:[~2013-10-14 18:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-14 18:38 su at cs dot ucdavis.edu [this message]
2013-10-15  8:22 ` [Bug rtl-optimization/58726] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2013-10-18 19:55 ` mikpelinux at gmail dot com
2013-11-05 15:03 ` rguenth at gcc dot gnu.org
2013-12-03 19:25 ` jakub at gcc dot gnu.org
2013-12-03 19:51 ` jakub at gcc dot gnu.org
2013-12-04 11:25 ` jakub at gcc dot gnu.org
2013-12-04 15:51 ` jakub at gcc dot gnu.org
2013-12-04 15:56 ` [Bug rtl-optimization/58726] [4.7 " jakub at gcc dot gnu.org
2013-12-11 15:17 ` ebotcazou at gcc dot gnu.org
2014-02-22  8:57 ` ebotcazou at gcc dot gnu.org
2014-10-23  6:08 ` pinskia 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-58726-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).