aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2024-02-13 11:58:00 -0800
committerH.J. Lu <(no_default)>2024-02-13 12:05:09 -0800
commitab71fd7ac7a2307723117c796e7ae4d7e9711058 (patch)
tree18ae9818bbeb672b83a412a70e2f9e96354f0f18
parenta5d34b60c949e85aa3e213872fbc42f4eee7457b (diff)
downloadgcc-ab71fd7ac7a2307723117c796e7ae4d7e9711058.zip
gcc-ab71fd7ac7a2307723117c796e7ae4d7e9711058.tar.gz
gcc-ab71fd7ac7a2307723117c796e7ae4d7e9711058.tar.bz2
x86-64: Use push2/pop2 only if the incoming stack is 16-byte aligned
Since push2/pop2 requires 16-byte stack alignment, don't use them if the incoming stack isn't 16-byte aligned. gcc/ PR target/113876 * config/i386/i386.cc (ix86_pro_and_epilogue_can_use_push2pop2): Return false if the incoming stack isn't 16-byte aligned. gcc/testsuite/ PR target/113876 * gcc.target/i386/pr113876.c: New test.
-rw-r--r--gcc/config/i386/i386.cc6
-rw-r--r--gcc/testsuite/gcc.target/i386/pr113876.c10
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index dbb26e8..a4e1260 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -6807,6 +6807,12 @@ get_probe_interval (void)
static bool
ix86_pro_and_epilogue_can_use_push2pop2 (int nregs)
{
+ /* Use push2/pop2 only if the incoming stack is 16-byte aligned. */
+ unsigned int incoming_stack_boundary
+ = (crtl->parm_stack_boundary > ix86_incoming_stack_boundary
+ ? crtl->parm_stack_boundary : ix86_incoming_stack_boundary);
+ if (incoming_stack_boundary % 128 != 0)
+ return false;
int aligned = cfun->machine->fs.sp_offset % 16 == 0;
return TARGET_APX_PUSH2POP2
&& !cfun->machine->frame.save_regs_using_mov
diff --git a/gcc/testsuite/gcc.target/i386/pr113876.c b/gcc/testsuite/gcc.target/i386/pr113876.c
new file mode 100644
index 0000000..fbf26f6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr113876.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target { lp64 } } } */
+/* { dg-options "-O -mapxf -mpreferred-stack-boundary=3 -finstrument-functions -mcmodel=large" } */
+
+void
+bar (unsigned long *p)
+{
+ p[0] = 0;
+ p[1] = 0;
+ p[2] = 0;
+}