public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113912] New: push2/pop2 generated when stack isn't aligned to 16 bytes
@ 2024-02-13 20:59 hjl.tools at gmail dot com
2024-02-13 21:33 ` [Bug target/113912] " hjl.tools at gmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: hjl.tools at gmail dot com @ 2024-02-13 20:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113912
Bug ID: 113912
Summary: push2/pop2 generated when stack isn't aligned to 16
bytes
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: hjl.tools at gmail dot com
CC: crazylht at gmail dot com
Target Milestone: ---
Target: x86-64
[hjl@gnu-cfl-3 apx-1]$ cat x.c
extern int bar (int);
void foo ()
{
int a,b,c,d,e,f,i;
a = bar (5);
b = bar (a);
c = bar (b);
d = bar (c);
e = bar (d);
f = bar (e);
for (i = 1; i < 10; i++)
{
a += bar (a + i) + bar (b + i) +
bar (c + i) + bar (d + i) +
bar (e + i) + bar (f + i);
}
}
[hjl@gnu-cfl-3 apx-1]$ make
/export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/ -mapxf
-O2 -mpreferred-stack-boundary=3 -fomit-frame-pointer -S x.c
[hjl@gnu-cfl-3 apx-1]$ cat x.s
.file "x.c"
.text
.p2align 4
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
pushp %r15
.cfi_def_cfa_offset 16
.cfi_offset 15, -16
movl $5, %edi
push2p %r13, %r14
.cfi_def_cfa_offset 32
.cfi_offset 14, -24
.cfi_offset 13, -32
push2p %rbp, %r12
.cfi_def_cfa_offset 48
.cfi_offset 12, -40
.cfi_offset 6, -48
pushp %rbx
.cfi_def_cfa_offset 56
.cfi_offset 3, -56
movl $1, %ebx
subq $8, %rsp
.cfi_def_cfa_offset 64
call bar
movl %eax, %edi
movl %eax, %r12d
call bar
movl %eax, %edi
movl %eax, %r15d
call bar
movl %eax, %edi
movl %eax, %r14d
call bar
movl %eax, %edi
movl %eax, %r13d
call bar
movl %eax, %edi
movl %eax, (%rsp)
call bar
movl %eax, 4(%rsp)
.p2align 4,,10
.p2align 3
.L2:
leal (%r12,%rbx), %edi
call bar
leal (%r15,%rbx), %edi
movl %eax, %ebp
call bar
leal (%r14,%rbx), %edi
addl %eax, %ebp
call bar
leal 0(%r13,%rbx), %edi
addl %eax, %ebp
call bar
addl %ebx, (%rsp), %edi
addl %eax, %ebp
call bar
addl %ebx, 4(%rsp), %edi
addl $1, %ebx
addl %eax, %ebp
call bar
addl %eax, %ebp
addl %ebp, %r12d
cmpl $10, %ebx
jne .L2
addq $8, %rsp
.cfi_def_cfa_offset 56
popp %rbx
.cfi_def_cfa_offset 48
pop2p %r12, %rbp
.cfi_restore 12
.cfi_restore 6
.cfi_def_cfa_offset 32
pop2p %r14, %r13
.cfi_restore 14
.cfi_restore 13
.cfi_def_cfa_offset 16
popp %r15
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
.ident "GCC: (GNU) 14.0.1 20240213 (experimental)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-cfl-3 apx-1]$
With -mpreferred-stack-boundary=3, the coming stack is 8-byte aligned.
push2/pop2
shouldn't be generated in this case.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/113912] push2/pop2 generated when stack isn't aligned to 16 bytes
2024-02-13 20:59 [Bug target/113912] New: push2/pop2 generated when stack isn't aligned to 16 bytes hjl.tools at gmail dot com
@ 2024-02-13 21:33 ` hjl.tools at gmail dot com
2024-02-18 15:38 ` cvs-commit at gcc dot gnu.org
2024-02-18 15:39 ` hjl.tools at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: hjl.tools at gmail dot com @ 2024-02-13 21:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113912
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
Last reconfirmed| |2024-02-13
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
A patch is at
https://patchwork.sourceware.org/project/gcc/list/?series=30889
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/113912] push2/pop2 generated when stack isn't aligned to 16 bytes
2024-02-13 20:59 [Bug target/113912] New: push2/pop2 generated when stack isn't aligned to 16 bytes hjl.tools at gmail dot com
2024-02-13 21:33 ` [Bug target/113912] " hjl.tools at gmail dot com
@ 2024-02-18 15:38 ` cvs-commit at gcc dot gnu.org
2024-02-18 15:39 ` hjl.tools at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-18 15:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113912
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:
https://gcc.gnu.org/g:853eb57759967335a7ea872e6a0721034db6fabd
commit r14-9058-g853eb57759967335a7ea872e6a0721034db6fabd
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Feb 13 13:32:44 2024 -0800
x86-64: Generate push2/pop2 only if the incoming stack is 16-byte aligned
Since push2/pop2 requires 16-byte stack alignment, don't generate them
if the incoming stack isn't 16-byte aligned.
gcc/
PR target/113912
* config/i386/i386.cc (ix86_can_use_push2pop2): New.
(ix86_pro_and_epilogue_can_use_push2pop2): Use it.
(ix86_emit_save_regs): Don't generate push2 if
ix86_can_use_push2pop2 return false.
(ix86_expand_epilogue): Don't generate pop2 if
ix86_can_use_push2pop2 return false.
gcc/testsuite/
PR target/113912
* gcc.target/i386/apx-push2pop2-2.c: New test.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug target/113912] push2/pop2 generated when stack isn't aligned to 16 bytes
2024-02-13 20:59 [Bug target/113912] New: push2/pop2 generated when stack isn't aligned to 16 bytes hjl.tools at gmail dot com
2024-02-13 21:33 ` [Bug target/113912] " hjl.tools at gmail dot com
2024-02-18 15:38 ` cvs-commit at gcc dot gnu.org
@ 2024-02-18 15:39 ` hjl.tools at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: hjl.tools at gmail dot com @ 2024-02-18 15:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113912
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-18 15:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13 20:59 [Bug target/113912] New: push2/pop2 generated when stack isn't aligned to 16 bytes hjl.tools at gmail dot com
2024-02-13 21:33 ` [Bug target/113912] " hjl.tools at gmail dot com
2024-02-18 15:38 ` cvs-commit at gcc dot gnu.org
2024-02-18 15:39 ` hjl.tools at gmail dot com
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).