public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: "H. J. Lu" <hjl.tools@gmail.com>
Subject: [PATCH, i386]: Allow -mpreferred-stack-boundary=3 for 64-bit targets independently of SSE (PR 53383)
Date: Tue, 28 Mar 2017 17:02:00 -0000	[thread overview]
Message-ID: <CAFULd4YEx4tau0HOZ0pdEr0Gp23eq46tUjadiFSXnY7jZjYqrA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1001 bytes --]

Hello!

As argued in the PR [1], limiting -mpreferred-stack-boundary=3 only
for non-SSE 64bit targets represent artificial limitation, restricting
compiler functionality and user freedom.

Attached patch allows -mpreferred-stack-boundary=3 in all cases. The
compiler will align stack when needed, imposing a small runtime
penalty for functions that require 16-byte alignment.

2017-03-28  Uros Bizjak  <ubizjak@gmail.com>

    PR target/53383
    * config/i386/i386.c (ix86_option_override_internal): Always
    allow -mpreferred-stack-boundary=3 for 64-bit targets.

testsuite/ChangeLog:

2017-03-28  Uros Bizjak  <ubizjak@gmail.com>

    PR target/53383
    * gcc.target/i386/pr53383-1.c (dg-options): Remove -mno-sse.
    * gcc.target/i386/pr53383-2.c (dg-options): Ditto.
    * gcc.target/i386/pr53383-3.c (dg-options): Ditto.

Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383#c25

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 2106 bytes --]

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 246531)
+++ config/i386/i386.c	(working copy)
@@ -5927,9 +5927,8 @@ ix86_option_override_internal (bool main_args_p,
   ix86_preferred_stack_boundary = PREFERRED_STACK_BOUNDARY_DEFAULT;
   if (opts_set->x_ix86_preferred_stack_boundary_arg)
     {
-      int min = (TARGET_64BIT_P (opts->x_ix86_isa_flags)
-		 ? (TARGET_SSE_P (opts->x_ix86_isa_flags) ? 4 : 3) : 2);
-      int max = (TARGET_SEH ? 4 : 12);
+      int min = TARGET_64BIT_P (opts->x_ix86_isa_flags)? 3 : 2;
+      int max = TARGET_SEH ? 4 : 12;
 
       if (opts->x_ix86_preferred_stack_boundary_arg < min
 	  || opts->x_ix86_preferred_stack_boundary_arg > max)
Index: testsuite/gcc.target/i386/pr53383-1.c
===================================================================
--- testsuite/gcc.target/i386/pr53383-1.c	(revision 246531)
+++ testsuite/gcc.target/i386/pr53383-1.c	(working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -mno-sse -mpreferred-stack-boundary=3" } */
+/* { dg-options "-O2 -mpreferred-stack-boundary=3" } */
 
 int
 bar (int x)
Index: testsuite/gcc.target/i386/pr53383-2.c
===================================================================
--- testsuite/gcc.target/i386/pr53383-2.c	(revision 246531)
+++ testsuite/gcc.target/i386/pr53383-2.c	(working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -mno-sse -mpreferred-stack-boundary=3 -mincoming-stack-boundary=3" } */
+/* { dg-options "-O2 -mpreferred-stack-boundary=3 -mincoming-stack-boundary=3" } */
 
 int
 bar (int x)
Index: testsuite/gcc.target/i386/pr53383-3.c
===================================================================
--- testsuite/gcc.target/i386/pr53383-3.c	(revision 246531)
+++ testsuite/gcc.target/i386/pr53383-3.c	(working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -mno-sse -mincoming-stack-boundary=3 -mpreferred-stack-boundary=3" } */
+/* { dg-options "-O2 -mincoming-stack-boundary=3 -mpreferred-stack-boundary=3" } */
 
 int
 bar (int x)

                 reply	other threads:[~2017-03-28 17:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFULd4YEx4tau0HOZ0pdEr0Gp23eq46tUjadiFSXnY7jZjYqrA@mail.gmail.com \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).