public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP
@ 2012-09-10 11:04 rearnsha at gcc dot gnu.org
  2012-09-10 11:54 ` [Bug rtl-optimization/54540] " rguenth at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2012-09-10 11:04 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54540
           Summary: [4.8 regression] postreload incorrectly simplifies
                    stack adjustment into constant load into SP
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rearnsha@gcc.gnu.org
            Target: arm-linux-gnueabi


This is probably a latent bug that has been exposed by a recent change to the
ARM back-end.

In the testcase, when compiled with:

/work/rearnsha/scratch/gnu/gcc/trunk/gcc/cc1plus default.ii -O2 -mcpu=cortex-a9
-mthumb --std=c++11

For the function

_Z8run_testIN9__gnu_cxx33simd_fast_mersenne_twister_engineIjLj132049ELj110ELj19E
Lj1ELj21ELj1ELj4294949727ELj4218339221ELj4294901754ELj3489103871ELj1ELj0ELj34111
48800ELj3353943165EEEEvSt16initializer_listINT_11result_typeEE

the stack pointer adjustment in the prologue ends up being optimized into 

  ldr  sp, [pc, #offs]  

which is a load from the constant pool.

After register allocation we have:

    2 r151:SI=sp:SI-0x4080
    3 sp:SI=r151:SI-0x20
      REG_DEAD: r151:SI
      REG_EQUAL: sp:SI-0x40a0
    5 r152:SI=sp:SI+0xf

However, a reload is needed and the reload pass generates

    2 r3:SI=sp:SI-0x4080
  205 sp:SI=0xffffffffffffffe0
    3 sp:SI=sp:SI+r3:SI
      REG_EQUAL: sp:SI-0x40a0
    5 r8:SI=sp:SI+0xf

Note that insn 3 still has a note that describes the result as being an
adjustment to SP.

Postreload somehow then converts this into 

    2 r3:SI=sp:SI-0x4080
  205 sp:SI=0xffffffffffffffef
    5 r8:SI=sp:SI+r3:SI

Which of course is not at all the same result.

There are two issues going on here:

One, reload is using SP as a scratch register.  This violates stack integrity
rules.  If an interrupt or signal occurred while SP was invalid the program
would probably crash.  This is a reload bug.

Two, SP is never correctly updated to the final value, which means that the
code crashes at run time.  This may also be a reload bug, but it might also be
a post-reload one (or both).


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

* [Bug rtl-optimization/54540] [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
@ 2012-09-10 11:54 ` rguenth at gcc dot gnu.org
  2012-09-10 12:46 ` rearnsha at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-09-10 11:54 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.8.0


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

* [Bug rtl-optimization/54540] [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
  2012-09-10 11:54 ` [Bug rtl-optimization/54540] " rguenth at gcc dot gnu.org
@ 2012-09-10 12:46 ` rearnsha at gcc dot gnu.org
  2012-09-10 13:53 ` segher at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2012-09-10 12:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Richard Earnshaw <rearnsha at gcc dot gnu.org> 2012-09-10 12:46:29 UTC ---
Created attachment 28160
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28160
Testcase (not reduced)


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

* [Bug rtl-optimization/54540] [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
  2012-09-10 11:54 ` [Bug rtl-optimization/54540] " rguenth at gcc dot gnu.org
  2012-09-10 12:46 ` rearnsha at gcc dot gnu.org
@ 2012-09-10 13:53 ` segher at gcc dot gnu.org
  2012-09-14 17:11 ` rearnsha at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: segher at gcc dot gnu.org @ 2012-09-10 13:53 UTC (permalink / raw)
  To: gcc-bugs

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

Segher Boessenkool <segher at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-09-10
     Ever Confirmed|0                           |1

--- Comment #2 from Segher Boessenkool <segher at gcc dot gnu.org> 2012-09-10 13:52:40 UTC ---
Confirmed.


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

* [Bug rtl-optimization/54540] [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-09-10 13:53 ` segher at gcc dot gnu.org
@ 2012-09-14 17:11 ` rearnsha at gcc dot gnu.org
  2012-09-15  9:57 ` rearnsha at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2012-09-14 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Earnshaw <rearnsha at gcc dot gnu.org> 2012-09-14 17:10:53 UTC ---
Author: rearnsha
Date: Fri Sep 14 17:10:45 2012
New Revision: 191307

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191307
Log:
    PR target/54516
    PR rtl-optimization/54540
    * reload.c (find_dummy_reload): Don't use OUT as a reload reg
    for IN if it overlaps a fixed register.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/reload.c


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

* [Bug rtl-optimization/54540] [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-09-14 17:11 ` rearnsha at gcc dot gnu.org
@ 2012-09-15  9:57 ` rearnsha at gcc dot gnu.org
  2012-11-20  9:27 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2012-09-15  9:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Earnshaw <rearnsha at gcc dot gnu.org> 2012-09-15 09:57:34 UTC ---
(In reply to comment #3)
> Author: rearnsha
> Date: Fri Sep 14 17:10:45 2012
> New Revision: 191307
> 
Has probably made the post-reload issues go latent again.


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

* [Bug rtl-optimization/54540] [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2012-09-15  9:57 ` rearnsha at gcc dot gnu.org
@ 2012-11-20  9:27 ` jakub at gcc dot gnu.org
  2012-11-20  9:35 ` rearnsha at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-11-20  9:27 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-11-20 09:26:52 UTC ---
Can this be closed now?


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

* [Bug rtl-optimization/54540] [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2012-11-20  9:27 ` jakub at gcc dot gnu.org
@ 2012-11-20  9:35 ` rearnsha at gcc dot gnu.org
  2012-11-20 11:09 ` [Bug rtl-optimization/54540] " steven at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2012-11-20  9:35 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #6 from Richard Earnshaw <rearnsha at gcc dot gnu.org> 2012-11-20 09:35:02 UTC ---
(In reply to comment #5)
> Can this be closed now?

Well the comment 4 is still relevant, I suspect that there are still latent
issues in postreload.


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

* [Bug rtl-optimization/54540] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2012-11-20  9:35 ` rearnsha at gcc dot gnu.org
@ 2012-11-20 11:09 ` steven at gcc dot gnu.org
  2013-03-22 14:47 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: steven at gcc dot gnu.org @ 2012-11-20 11:09 UTC (permalink / raw)
  To: gcc-bugs


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

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |steven at gcc dot gnu.org

--- Comment #7 from Steven Bosscher <steven at gcc dot gnu.org> 2012-11-20 11:09:12 UTC ---
(In reply to comment #6)
> (In reply to comment #5)
> > Can this be closed now?
> 
> Well the comment 4 is still relevant, I suspect that there are still latent
> issues in postreload.

Are we going to keep a bug report open because of a _suspected_ bug, with
no test case to reproduce the problem with the current trunk?  Any new bug
report without a test case would be almost immediately closed as INVALID,
and I see no good reason to do things differently for an existing PR with
a fix applied and no test case remaining to reproduce the issue.

Have you at least looked at postreload (using a compiler without your fix
for reload) to see where things go bad?  I suspect the bad insn is created
in reload_combine_recognize_pattern.  You could try to rule out move2add
using debug counters (-fdbg-cnt=cse2_move2add:0) at least.


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

* [Bug rtl-optimization/54540] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2012-11-20 11:09 ` [Bug rtl-optimization/54540] " steven at gcc dot gnu.org
@ 2013-03-22 14:47 ` jakub at gcc dot gnu.org
  2013-05-31 11:00 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-03-22 14:47 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.0                       |4.8.1

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-03-22 14:45:27 UTC ---
GCC 4.8.0 is being released, adjusting target milestone.


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

* [Bug rtl-optimization/54540] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2013-03-22 14:47 ` jakub at gcc dot gnu.org
@ 2013-05-31 11:00 ` jakub at gcc dot gnu.org
  2013-10-16  9:51 ` jakub at gcc dot gnu.org
  2015-06-22 14:26 ` rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-05-31 11:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.1                       |4.8.2

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.1 has been released.


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

* [Bug rtl-optimization/54540] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2013-05-31 11:00 ` jakub at gcc dot gnu.org
@ 2013-10-16  9:51 ` jakub at gcc dot gnu.org
  2015-06-22 14:26 ` rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-10-16  9:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.2                       |4.8.3

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.2 has been released.


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

* [Bug rtl-optimization/54540] postreload incorrectly simplifies stack adjustment into constant load into SP
  2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
                   ` (10 preceding siblings ...)
  2013-10-16  9:51 ` jakub at gcc dot gnu.org
@ 2015-06-22 14:26 ` rguenth at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-22 14:26 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.3                       |---


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

end of thread, other threads:[~2015-06-22 14:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-10 11:04 [Bug rtl-optimization/54540] New: [4.8 regression] postreload incorrectly simplifies stack adjustment into constant load into SP rearnsha at gcc dot gnu.org
2012-09-10 11:54 ` [Bug rtl-optimization/54540] " rguenth at gcc dot gnu.org
2012-09-10 12:46 ` rearnsha at gcc dot gnu.org
2012-09-10 13:53 ` segher at gcc dot gnu.org
2012-09-14 17:11 ` rearnsha at gcc dot gnu.org
2012-09-15  9:57 ` rearnsha at gcc dot gnu.org
2012-11-20  9:27 ` jakub at gcc dot gnu.org
2012-11-20  9:35 ` rearnsha at gcc dot gnu.org
2012-11-20 11:09 ` [Bug rtl-optimization/54540] " steven at gcc dot gnu.org
2013-03-22 14:47 ` jakub at gcc dot gnu.org
2013-05-31 11:00 ` jakub at gcc dot gnu.org
2013-10-16  9:51 ` jakub at gcc dot gnu.org
2015-06-22 14:26 ` rguenth 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).