public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/65282] New: wrong code at -Os and above on x86_64-linux-gnu
@ 2015-03-02 20:48 su at cs dot ucdavis.edu
  2015-03-03  8:43 ` [Bug ipa/65282] [5 Regression] " mpolacek at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: su at cs dot ucdavis.edu @ 2015-03-02 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65282
           Summary: wrong code at -Os and above 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 miscompiles the following code on x86_64-linux at -Os and
above in both 32-bit and 64-bit modes. 

This is a regression from 4.9.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 20150302 (experimental) [trunk revision 221099] (GCC) 
$ 
$ gcc-trunk -O1 small.c; a.out
$ gcc-4.9.2 -Os small.c; a.out
$ 
$ gcc-trunk -Os small.c
$ ./a.out
Aborted (core dumped)
$ 


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


int a[2];
static int *b = &a[0], *c = &a[1];

int
main ()
{
  *c = 1;
  *b = 0;

  if (a[1] != 1)
    __builtin_abort ();

  return 0;
}


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

* [Bug ipa/65282] [5 Regression] wrong code at -Os and above on x86_64-linux-gnu
  2015-03-02 20:48 [Bug tree-optimization/65282] New: wrong code at -Os and above on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2015-03-03  8:43 ` mpolacek at gcc dot gnu.org
  2015-03-03 10:41 ` marxin at gcc dot gnu.org
  2015-03-03 12:09 ` marxin at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-03-03  8:43 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |ipa

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Another ICF issue...


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

* [Bug ipa/65282] [5 Regression] wrong code at -Os and above on x86_64-linux-gnu
  2015-03-02 20:48 [Bug tree-optimization/65282] New: wrong code at -Os and above on x86_64-linux-gnu su at cs dot ucdavis.edu
  2015-03-03  8:43 ` [Bug ipa/65282] [5 Regression] " mpolacek at gcc dot gnu.org
@ 2015-03-03 10:41 ` marxin at gcc dot gnu.org
  2015-03-03 12:09 ` marxin at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: marxin at gcc dot gnu.org @ 2015-03-03 10:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Patch has been just sent to ML:
https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00130.html

Thanks,
Martin
>From gcc-bugs-return-479138-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Mar 03 11:00:31 2015
Return-Path: <gcc-bugs-return-479138-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 87063 invoked by alias); 3 Mar 2015 11:00:31 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 86997 invoked by uid 48); 3 Mar 2015 11:00:23 -0000
From: "gjl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65296] [avr] fix various issues with specs file generation
Date: Tue, 03 Mar 2015 11:00:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: gjl at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P4
X-Bugzilla-Assigned-To: gjl at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: priority bug_status cf_reconfirmed_on assigned_to everconfirmed
Message-ID: <bug-65296-4-ZNKDwSqtAC@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65296-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65296-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-03/txt/msg00282.txt.bz2
Content-length: 537

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide296

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2015-03-03
           Assignee|unassigned at gcc dot gnu.org      |gjl at gcc dot gnu.org
     Ever confirmed|0                           |1


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

* [Bug ipa/65282] [5 Regression] wrong code at -Os and above on x86_64-linux-gnu
  2015-03-02 20:48 [Bug tree-optimization/65282] New: wrong code at -Os and above on x86_64-linux-gnu su at cs dot ucdavis.edu
  2015-03-03  8:43 ` [Bug ipa/65282] [5 Regression] " mpolacek at gcc dot gnu.org
  2015-03-03 10:41 ` marxin at gcc dot gnu.org
@ 2015-03-03 12:09 ` marxin at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: marxin at gcc dot gnu.org @ 2015-03-03 12:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Author: marxin
Date: Tue Mar  3 12:09:13 2015
New Revision: 221146

URL: https://gcc.gnu.org/viewcvs?rev=221146&root=gcc&view=rev
Log:
Fix PR ipa/65282.

    * gcc.dg/ipa/PR65282.c: New test.
    PR ipa/65282
    * ipa-icf.c (sem_variable::equals): Fix wrong condition.


Added:
    trunk/gcc/testsuite/gcc.dg/ipa/PR65282.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-icf.c
    trunk/gcc/testsuite/ChangeLog
>From gcc-bugs-return-479149-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Mar 03 12:11:19 2015
Return-Path: <gcc-bugs-return-479149-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 11284 invoked by alias); 3 Mar 2015 12:11:19 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 10910 invoked by uid 48); 3 Mar 2015 12:11:16 -0000
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/65282] [5 Regression] wrong code at -Os and above on x86_64-linux-gnu
Date: Tue, 03 Mar 2015 12:11:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: ipa
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: marxin at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P1
X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-65282-4-o6hZR4ZzZ0@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65282-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65282-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-03/txt/msg00293.txt.bz2
Content-length: 440

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

Martin Liška <marxin at gcc dot gnu.org> changed:

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

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed in 5.0.
>From gcc-bugs-return-479150-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Mar 03 12:30:48 2015
Return-Path: <gcc-bugs-return-479150-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 83504 invoked by alias); 3 Mar 2015 12:30:48 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 83434 invoked by uid 48); 3 Mar 2015 12:30:44 -0000
From: "law at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/64317] [5 Regression] Ineffective allocation of PIC base register
Date: Tue, 03 Mar 2015 12:30:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: missed-optimization, ra
X-Bugzilla-Severity: normal
X-Bugzilla-Who: law at redhat dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P1
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-64317-4-QX8gCm3oXg@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64317-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64317-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-03/txt/msg00294.txt.bz2
Content-length: 2160

https://gcc.gnu.org/bugzilla/show_bug.cgi?idd317

--- Comment #17 from Jeffrey A. Law <law at redhat dot com> ---
Thanks Vlad, that patch helped.  Prior to your patch we had 15 reloads of the
PIC register from memory, after your patch we have just 9.   However, several
of the remaining 9 seem to be redundant.

LRA never considers a block starting with a label as participating in an EBB.
That's overly conservative.  A block can participate in an EBB if all of its
predecessors are part of the same EBB.

That's particularly useful in CFGs like

    A
   /|
  / |
 B  |
  \ |
   \|
    C

[ Flow downward of course. ]


If we assume that B is the fallthru path, then LRA will try to make AB into an
EBB.  But it will not consider C because C will start with a label.  That
ultimately causes missed inheritances in this example.

As an example, we have this in the .reload dump:

[ BB 7 ]

(insn 848 94 582 7 (set (reg:SI 6 bp [107])
        (mem/c:SI (plus:SI (reg/f:SI 7 sp)
                (const_int 28 [0x1c])) [4 %sfp+-4 S4 A32])) k.c:22 90
{*movsi_internal}
     (nil))

[ ... ]

(jump_insn 99 98 100 7 (set (pc)
        (if_then_else (geu (reg:CC 17 flags)
                (const_int 0 [0]))
            (label_ref 103)
            (pc))) k.c:18 613 {*jcc_1}
     (int_list:REG_BR_PROB 5000 (nil))

[ BB 8 ]

(insn 584 100 101 8 (set (reg:SI 3 bx [107])
        (reg:SI 6 bp [107])) k.c:19 90 {*movsi_internal}
     (nil))

[ Note we inherited the value in %ebp, this is good. ]

[ ... ]

[ BB 9 ]

(code_label 103 102 104 9 5 "" [1 uses])

[ ... ]

(insn 850 105 585 9 (set (reg:SI 6 bp [107])
        (mem/c:SI (plus:SI (reg/f:SI 7 sp)
                (const_int 28 [0x1c])) [4 %sfp+-4 S4 A32])) k.c:22 90
{*movsi_internal}
     (nil))

Note insn 850 which reloads the value from memory again.  We correctly formed
an EBB with BB7 and BB8, but we really should have extended that to BB9.

It appears that fixing this would improve things further.  It's also the case
that the post-reload passes aren't doing as good of a job at cleaning things up
as they should, so  I'll look at that in parallel if you can investigate the
LRA side of things.


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

end of thread, other threads:[~2015-03-03 12:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-02 20:48 [Bug tree-optimization/65282] New: wrong code at -Os and above on x86_64-linux-gnu su at cs dot ucdavis.edu
2015-03-03  8:43 ` [Bug ipa/65282] [5 Regression] " mpolacek at gcc dot gnu.org
2015-03-03 10:41 ` marxin at gcc dot gnu.org
2015-03-03 12:09 ` marxin 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).