public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/63659] New: wrong code at -O2 and -O3 on x86_64-linux-gnu
@ 2014-10-27 16:43 su at cs dot ucdavis.edu
  2014-10-27 16:44 ` [Bug tree-optimization/63659] [4.8/4.9/5 Regression] " jakub at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-10-27 16:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 63659
           Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk (as well as 4.8.x and 4.9.x) miscompiles the following
code on x86_64-linux at -O2 and -O3 in both 32-bit and 64-bit modes. 

This is a regression from 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/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 5.0.0 20141025 (experimental) [trunk revision 216691] (GCC) 

$ gcc-trunk -Os small.c; a.out
$ gcc-4.7 -O2 small.c; a.out
$ 
$ gcc-trunk -O2 small.c
$ ./a.out
Aborted (core dumped)
$     


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


int a, b, c, *d = &b, g, h, i;
unsigned char e;
char f;

int
main ()
{
  for (; a;)
    {
      for (a = 0; a; a++)
    for (; c; c++)
      ;
      if (i)
    break;
    }
  char j = c, k = -1, l;
  l = g = j >> h;
  f = l == 0 ? k : k % l;
  e = 0 ? 0 : f;
  *d = e;

  if (b != 255) 
    __builtin_abort (); 

  return 0;
}


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

* [Bug tree-optimization/63659] [4.8/4.9/5 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
  2014-10-27 16:43 [Bug tree-optimization/63659] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2014-10-27 16:44 ` jakub at gcc dot gnu.org
  2014-10-27 17:32 ` [Bug rtl-optimization/63659] " jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-10-27 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-10-27
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |uweigand at gcc dot gnu.org
   Target Milestone|---                         |4.8.4
            Summary|wrong code at -O2 and -O3   |[4.8/4.9/5 Regression]
                   |on x86_64-linux-gnu         |wrong code at -O2 and -O3
                   |                            |on x86_64-linux-gnu
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r186278.


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

* [Bug rtl-optimization/63659] [4.8/4.9/5 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
  2014-10-27 16:43 [Bug tree-optimization/63659] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2014-10-27 16:44 ` [Bug tree-optimization/63659] [4.8/4.9/5 Regression] " jakub at gcc dot gnu.org
@ 2014-10-27 17:32 ` jakub at gcc dot gnu.org
  2014-10-27 18:36 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-10-27 17:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Seems this is a REE bug.  Before REE pass, we have:
(insn 4 27 76 6 (set (reg/v:QI 0 ax [orig:59 k ] [59])
        (const_int -1 [0xffffffffffffffff])) pr63659.c:18 66 {*movqi_internal}
     (expr_list:REG_EQUAL (const_int -1 [0xffffffffffffffff])
        (nil)))
...
(insn 46 44 80 9 (set (reg:SI 0 ax [orig:85 f.10 ] [85])
        (zero_extend:SI (reg/v:QI 0 ax [orig:59 k ] [59]))) pr63659.c:20 118
{*zero_extendqisi2}
     (nil))
...
(insn 47 80 48 9 (set (mem:SI (reg/f:DI 1 dx [orig:84 d ] [84]) [3 *d.11_19+0
S4 A32])
        (reg:SI 0 ax [orig:85 f.10 ] [85])) pr63659.c:20 64 {*movsi_internal}
     (nil))
REE changes that to:
(insn 4 27 76 6 (set (reg:SI 0 ax)
        (const_int 255 [0xff])) pr63659.c:18 64 {*movsi_internal}
     (expr_list:REG_EQUAL (const_int -1 [0xffffffffffffffff])
        (nil)))
...
(insn 47 80 48 9 (set (mem:SI (reg/f:DI 1 dx [orig:84 d ] [84]) [3 *d.11_19+0
S4 A32])
        (reg:SI 0 ax [orig:85 f.10 ] [85])) pr63659.c:20 64 {*movsi_internal}
     (nil))
and there is a (set (reg:SI 0 ax) (const_int -1)) insn in another block.
CSA pass then hoists (set (reg:SI 0 ax) (const_int -1)) before the loop.
The bug is that the REE pass left an invalid REG_EQUAL note which the CSA pass
then used.  0xff value is -1 in QImode, but not after zero-extension.
So I think we'll need to teach the REE pass to adjust or drop
REG_EQUAL/REG_EQUIV notes.


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

* [Bug rtl-optimization/63659] [4.8/4.9/5 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
  2014-10-27 16:43 [Bug tree-optimization/63659] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2014-10-27 16:44 ` [Bug tree-optimization/63659] [4.8/4.9/5 Regression] " jakub at gcc dot gnu.org
  2014-10-27 17:32 ` [Bug rtl-optimization/63659] " jakub at gcc dot gnu.org
@ 2014-10-27 18:36 ` jakub at gcc dot gnu.org
  2014-10-31 19:48 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-10-27 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 33820
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33820&action=edit
gcc5-pr63659.patch

Untested fix.


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

* [Bug rtl-optimization/63659] [4.8/4.9/5 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
  2014-10-27 16:43 [Bug tree-optimization/63659] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (2 preceding siblings ...)
  2014-10-27 18:36 ` jakub at gcc dot gnu.org
@ 2014-10-31 19:48 ` jakub at gcc dot gnu.org
  2014-11-18 10:32 ` [Bug rtl-optimization/63659] [4.8/4.9 " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-10-31 19:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Oct 31 19:42:39 2014
New Revision: 216985

URL: https://gcc.gnu.org/viewcvs?rev=216985&root=gcc&view=rev
Log:
    PR rtl-optimization/63659
    * ree.c (update_reg_equal_equiv_notes): New function.
    (combine_set_extension, transform_ifelse): Use it.

    * gcc.c-torture/execute/pr63659.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr63659.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ree.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug rtl-optimization/63659] [4.8/4.9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
  2014-10-27 16:43 [Bug tree-optimization/63659] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (3 preceding siblings ...)
  2014-10-31 19:48 ` jakub at gcc dot gnu.org
@ 2014-11-18 10:32 ` jakub at gcc dot gnu.org
  2014-11-28 13:33 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-18 10:32 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.8/4.9/5 Regression]      |[4.8/4.9 Regression] wrong
                   |wrong code at -O2 and -O3   |code at -O2 and -O3 on
                   |on x86_64-linux-gnu         |x86_64-linux-gnu

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.


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

* [Bug rtl-optimization/63659] [4.8/4.9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
  2014-10-27 16:43 [Bug tree-optimization/63659] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (4 preceding siblings ...)
  2014-11-18 10:32 ` [Bug rtl-optimization/63659] [4.8/4.9 " jakub at gcc dot gnu.org
@ 2014-11-28 13:33 ` jakub at gcc dot gnu.org
  2014-11-28 17:04 ` jakub at gcc dot gnu.org
  2014-11-28 17:09 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-28 13:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Nov 28 13:32:57 2014
New Revision: 218150

URL: https://gcc.gnu.org/viewcvs?rev=218150&root=gcc&view=rev
Log:
    Backported from mainline
    2014-10-31  Jakub Jelinek  <jakub@redhat.com>

    PR rtl-optimization/63659
    * ree.c (update_reg_equal_equiv_notes): New function.
    (combine_set_extension, transform_ifelse): Use it.

    * gcc.c-torture/execute/pr63659.c: New test.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/pr63659.c
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/ree.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog


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

* [Bug rtl-optimization/63659] [4.8/4.9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
  2014-10-27 16:43 [Bug tree-optimization/63659] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (5 preceding siblings ...)
  2014-11-28 13:33 ` jakub at gcc dot gnu.org
@ 2014-11-28 17:04 ` jakub at gcc dot gnu.org
  2014-11-28 17:09 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-28 17:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Nov 28 17:03:55 2014
New Revision: 218166

URL: https://gcc.gnu.org/viewcvs?rev=218166&root=gcc&view=rev
Log:
    Backported from mainline
    2014-10-31  Jakub Jelinek  <jakub@redhat.com>

    PR rtl-optimization/63659
    * ree.c (update_reg_equal_equiv_notes): New function.
    (combine_set_extension, transform_ifelse): Use it.

    * gcc.c-torture/execute/pr63659.c: New test.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.c-torture/execute/pr63659.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/ree.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


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

* [Bug rtl-optimization/63659] [4.8/4.9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu
  2014-10-27 16:43 [Bug tree-optimization/63659] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (6 preceding siblings ...)
  2014-11-28 17:04 ` jakub at gcc dot gnu.org
@ 2014-11-28 17:09 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-28 17:09 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.


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

end of thread, other threads:[~2014-11-28 17:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-27 16:43 [Bug tree-optimization/63659] New: wrong code at -O2 and -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
2014-10-27 16:44 ` [Bug tree-optimization/63659] [4.8/4.9/5 Regression] " jakub at gcc dot gnu.org
2014-10-27 17:32 ` [Bug rtl-optimization/63659] " jakub at gcc dot gnu.org
2014-10-27 18:36 ` jakub at gcc dot gnu.org
2014-10-31 19:48 ` jakub at gcc dot gnu.org
2014-11-18 10:32 ` [Bug rtl-optimization/63659] [4.8/4.9 " jakub at gcc dot gnu.org
2014-11-28 13:33 ` jakub at gcc dot gnu.org
2014-11-28 17:04 ` jakub at gcc dot gnu.org
2014-11-28 17:09 ` jakub at gcc dot gnu.org

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).