public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/32849]  New: Unnecessary %esp inc/decrements in trivial code
@ 2007-07-21 23:30 vda dot linux at googlemail dot com
  2007-07-22  2:16 ` [Bug rtl-optimization/32849] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: vda dot linux at googlemail dot com @ 2007-07-21 23:30 UTC (permalink / raw)
  To: gcc-bugs

Compiling this code:

int f();
void g();
void t() { if (f()) g(); }

with gcc -Os -fomit-frame-pointer -S t.c produces:

        .file   "t.c"
        .text
.globl t
        .type   t, @function
t:
        subl    $12, %esp
        call    f
        testl   %eax, %eax
        je      .L4
        addl    $12, %esp
        jmp     g
.L4:
        addl    $12, %esp
        ret
        .size   t, .-t
        .ident  "GCC: (GNU) 4.2.1"
        .section        .note.GNU-stack,"",@progbits

subl/addl $12, %esp seem to be completely pointless to me here.


-- 
           Summary: Unnecessary %esp inc/decrements in trivial code
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vda dot linux at googlemail dot com
 GCC build triplet: i386-pc-linux-gnu
  GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu


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


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

* [Bug rtl-optimization/32849] Unnecessary %esp inc/decrements in trivial code
  2007-07-21 23:30 [Bug rtl-optimization/32849] New: Unnecessary %esp inc/decrements in trivial code vda dot linux at googlemail dot com
@ 2007-07-22  2:16 ` pinskia at gcc dot gnu dot org
  2007-07-22 10:16 ` vda dot linux at googlemail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-22  2:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-07-22 02:16 -------
>subl/addl $12, %esp seem to be completely pointless to me here.

It is needed to call f.


-- 


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


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

* [Bug rtl-optimization/32849] Unnecessary %esp inc/decrements in trivial code
  2007-07-21 23:30 [Bug rtl-optimization/32849] New: Unnecessary %esp inc/decrements in trivial code vda dot linux at googlemail dot com
  2007-07-22  2:16 ` [Bug rtl-optimization/32849] " pinskia at gcc dot gnu dot org
@ 2007-07-22 10:16 ` vda dot linux at googlemail dot com
  2007-07-22 16:47 ` [Bug regression/32849] " rask at sygehus dot dk
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vda dot linux at googlemail dot com @ 2007-07-22 10:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from vda dot linux at googlemail dot com  2007-07-22 10:16 -------
Well, gcc 3.4.3 disagrees with you:

# gcc -Os -fomit-frame-pointer -S t.c
# cat t.s
        .file   "t.c"
        .text
.globl t
        .type   t, @function
t:
        call    f
        testl   %eax, %eax
        je      .L1
        jmp     g
.L1:
        ret
        .size   t, .-t
        .section        .note.GNU-stack,"",@progbits
        .ident  "GCC: (GNU) 3.4.3"


-- 


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


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

* [Bug regression/32849] Unnecessary %esp inc/decrements in trivial code
  2007-07-21 23:30 [Bug rtl-optimization/32849] New: Unnecessary %esp inc/decrements in trivial code vda dot linux at googlemail dot com
  2007-07-22  2:16 ` [Bug rtl-optimization/32849] " pinskia at gcc dot gnu dot org
  2007-07-22 10:16 ` vda dot linux at googlemail dot com
@ 2007-07-22 16:47 ` rask at sygehus dot dk
  2007-07-22 21:32 ` vda dot linux at googlemail dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rask at sygehus dot dk @ 2007-07-22 16:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rask at sygehus dot dk  2007-07-22 16:47 -------
That is a known bug in GCC 3.4.3, causing the SSE code in f() to segfault.


-- 


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


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

* [Bug regression/32849] Unnecessary %esp inc/decrements in trivial code
  2007-07-21 23:30 [Bug rtl-optimization/32849] New: Unnecessary %esp inc/decrements in trivial code vda dot linux at googlemail dot com
                   ` (2 preceding siblings ...)
  2007-07-22 16:47 ` [Bug regression/32849] " rask at sygehus dot dk
@ 2007-07-22 21:32 ` vda dot linux at googlemail dot com
  2007-07-22 22:56 ` rask at sygehus dot dk
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vda dot linux at googlemail dot com @ 2007-07-22 21:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from vda dot linux at googlemail dot com  2007-07-22 21:32 -------
I am confused...
How does reserving 12 bytes on stack can help to prevent a segfault?
I can imagine how aligning the stack can help, but here gcc 4.2.1 does
something diffrent.

Maybe just throw an URL to more info about segfault of gcc 3.4.3-produced code
at me.


-- 


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


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

* [Bug regression/32849] Unnecessary %esp inc/decrements in trivial code
  2007-07-21 23:30 [Bug rtl-optimization/32849] New: Unnecessary %esp inc/decrements in trivial code vda dot linux at googlemail dot com
                   ` (3 preceding siblings ...)
  2007-07-22 21:32 ` vda dot linux at googlemail dot com
@ 2007-07-22 22:56 ` rask at sygehus dot dk
  2007-07-23  0:15 ` vda dot linux at googlemail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rask at sygehus dot dk @ 2007-07-22 22:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rask at sygehus dot dk  2007-07-22 22:56 -------
The point is exactly to align the stack. The call instruction decrements %esp
by 4 bytes, so GCC has to decrement %esp by another 12 bytes to keep the stack
aligned. See also bug target/13685.


-- 


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


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

* [Bug regression/32849] Unnecessary %esp inc/decrements in trivial code
  2007-07-21 23:30 [Bug rtl-optimization/32849] New: Unnecessary %esp inc/decrements in trivial code vda dot linux at googlemail dot com
                   ` (4 preceding siblings ...)
  2007-07-22 22:56 ` rask at sygehus dot dk
@ 2007-07-23  0:15 ` vda dot linux at googlemail dot com
  2007-07-23 20:50 ` vda dot linux at googlemail dot com
  2007-07-24 19:11 ` pbrook at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: vda dot linux at googlemail dot com @ 2007-07-23  0:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from vda dot linux at googlemail dot com  2007-07-23 00:15 -------
Oh *shit*. I see. Why, oh why you didn't go for aligning stack in fuctions
which decided they need to use instructions which require alignment? And ONLY
that functions? Why everyone needs to pay this tax now?

Oh well...


-- 


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


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

* [Bug regression/32849] Unnecessary %esp inc/decrements in trivial code
  2007-07-21 23:30 [Bug rtl-optimization/32849] New: Unnecessary %esp inc/decrements in trivial code vda dot linux at googlemail dot com
                   ` (5 preceding siblings ...)
  2007-07-23  0:15 ` vda dot linux at googlemail dot com
@ 2007-07-23 20:50 ` vda dot linux at googlemail dot com
  2007-07-24 19:11 ` pbrook at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: vda dot linux at googlemail dot com @ 2007-07-23 20:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from vda dot linux at googlemail dot com  2007-07-23 20:50 -------
I want to apologise. Apparently this behavior (16-byte stack alignment) can be
turned off with an option => I can still have just word-aligned stack. As long
as that still works, I am a more-or-less happy camper.

Sorry guys.


-- 


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


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

* [Bug regression/32849] Unnecessary %esp inc/decrements in trivial code
  2007-07-21 23:30 [Bug rtl-optimization/32849] New: Unnecessary %esp inc/decrements in trivial code vda dot linux at googlemail dot com
                   ` (6 preceding siblings ...)
  2007-07-23 20:50 ` vda dot linux at googlemail dot com
@ 2007-07-24 19:11 ` pbrook at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: pbrook at gcc dot gnu dot org @ 2007-07-24 19:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pbrook at gcc dot gnu dot org  2007-07-24 19:11 -------
You can use -mpreferred-stack-boundary=2 to disable this feature if you know
you're never going to need the additional stack alignment.

The compiler has know way of knowing whet the rest of your application does, so
has to make conservative assumptions.

If 16-byte alignment is needed anywhere then all functions must preserve that
alignment. Dynamic stack realignment is sufficiently expensive that it's much
better to not allow the stack to get misaligned in the first place.


-- 

pbrook at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2007-07-24 19:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-21 23:30 [Bug rtl-optimization/32849] New: Unnecessary %esp inc/decrements in trivial code vda dot linux at googlemail dot com
2007-07-22  2:16 ` [Bug rtl-optimization/32849] " pinskia at gcc dot gnu dot org
2007-07-22 10:16 ` vda dot linux at googlemail dot com
2007-07-22 16:47 ` [Bug regression/32849] " rask at sygehus dot dk
2007-07-22 21:32 ` vda dot linux at googlemail dot com
2007-07-22 22:56 ` rask at sygehus dot dk
2007-07-23  0:15 ` vda dot linux at googlemail dot com
2007-07-23 20:50 ` vda dot linux at googlemail dot com
2007-07-24 19:11 ` pbrook at gcc dot gnu dot 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).