aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRobin Dapp <rdapp@linux.ibm.com>2018-07-17 12:05:07 +0000
committerRobin Dapp <rdapp@gcc.gnu.org>2018-07-17 12:05:07 +0000
commit22800d6629dd7a9dde96276a3d93dabe236e2ea6 (patch)
tree53cb086a3bea2fa755e0ca8f167c0d4c0c6dcc57 /gcc
parenta3bccfa17c34a937d0222ec084fe9ca97d88a01f (diff)
downloadgcc-22800d6629dd7a9dde96276a3d93dabe236e2ea6.zip
gcc-22800d6629dd7a9dde96276a3d93dabe236e2ea6.tar.gz
gcc-22800d6629dd7a9dde96276a3d93dabe236e2ea6.tar.bz2
S/390: Set default function alignment to 16.
gcc/ChangeLog: 2018-07-17 Robin Dapp <rdapp@linux.ibm.com> * config/s390/s390.c (s390_default_align): Set default function alignment to 16. (s390_override_options_after_change): Call s390_default align. (s390_option_override_internal): Call s390_default_align. (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): Define. gcc/testsuite/ChangeLog: 2018-07-17 Robin Dapp <rdapp@linux.ibm.com> * gcc.target/s390/function-align1.c: New test. * gcc.target/s390/function-align2.c: New test. * gcc.target/s390/function-align3.c: New test. From-SVN: r262817
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/config/s390/s390.c22
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.target/s390/function-align1.c24
-rw-r--r--gcc/testsuite/gcc.target/s390/function-align2.c13
-rw-r--r--gcc/testsuite/gcc.target/s390/function-align3.c22
6 files changed, 95 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8ec7da0..2e04a56 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2018-07-17 Robin Dapp <rdapp@linux.ibm.com>
+
+ * config/s390/s390.c (s390_default_align): Set default function
+ alignment to 16.
+ (s390_override_options_after_change): Call s390_default align.
+ (s390_option_override_internal): Call s390_default_align.
+ (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): Define.
+
2018-07-17 Jakub Jelinek <jakub@redhat.com>
PR middle-end/86542
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index cb89694..81f1fba 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -15397,6 +15397,22 @@ s390_function_specific_restore (struct gcc_options *opts,
}
static void
+s390_default_align (struct gcc_options *opts)
+{
+ /* Set the default function alignment to 16 in order to get rid of
+ some unwanted performance effects. */
+ if (opts->x_flag_align_functions && !opts->x_str_align_functions
+ && opts->x_s390_tune >= PROCESSOR_2964_Z13)
+ opts->x_str_align_functions = "16";
+}
+
+static void
+s390_override_options_after_change (void)
+{
+ s390_default_align (&global_options);
+}
+
+static void
s390_option_override_internal (bool main_args_p,
struct gcc_options *opts,
const struct gcc_options *opts_set)
@@ -15633,6 +15649,9 @@ s390_option_override_internal (bool main_args_p,
opts->x_param_values,
opts_set->x_param_values);
+ /* Set the default alignment. */
+ s390_default_align (opts);
+
/* Call target specific restore function to do post-init work. At the moment,
this just sets opts->x_s390_cost_pointer. */
s390_function_specific_restore (opts, NULL);
@@ -16831,6 +16850,9 @@ s390_case_values_threshold (void)
#undef TARGET_PASS_BY_REFERENCE
#define TARGET_PASS_BY_REFERENCE s390_pass_by_reference
+#undef TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE
+#define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE s390_override_options_after_change
+
#undef TARGET_FUNCTION_OK_FOR_SIBCALL
#define TARGET_FUNCTION_OK_FOR_SIBCALL s390_function_ok_for_sibcall
#undef TARGET_FUNCTION_ARG
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d0001f0..addeb04 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2018-07-17 Robin Dapp <rdapp@linux.ibm.com>
+
+ * gcc.target/s390/function-align1.c: New test.
+ * gcc.target/s390/function-align2.c: New test.
+ * gcc.target/s390/function-align3.c: New test.
+
2018-07-17 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/discr55.adb: New test.
diff --git a/gcc/testsuite/gcc.target/s390/function-align1.c b/gcc/testsuite/gcc.target/s390/function-align1.c
new file mode 100644
index 0000000..78fa563
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/function-align1.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -march=z13" } */
+
+#include <assert.h>
+#include <stdint.h>
+
+__attribute__((noinline))
+void foo1 () {}
+
+__attribute__((noinline))
+__attribute__((optimize("align-functions=32")))
+void foo2 () {}
+
+int main ()
+{
+ foo1 ();
+ foo2 ();
+
+ void *f = &foo1;
+ void *g = &foo2;
+
+ assert (((uintptr_t)f % 16) == 0);
+ assert (((uintptr_t)g % 32) == 0);
+}
diff --git a/gcc/testsuite/gcc.target/s390/function-align2.c b/gcc/testsuite/gcc.target/s390/function-align2.c
new file mode 100644
index 0000000..0d8e1ff
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/function-align2.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-Os -march=z13" } */
+
+void bar ()
+{
+ /* { dg-final { scan-assembler-times ".align\t8" 2 } } */
+}
+
+__attribute__((optimize("O2")))
+void baz ()
+{
+ /* { dg-final { scan-assembler-times ".align\t16" 1 } } */
+}
diff --git a/gcc/testsuite/gcc.target/s390/function-align3.c b/gcc/testsuite/gcc.target/s390/function-align3.c
new file mode 100644
index 0000000..adb7976
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/function-align3.c
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+/* { dg-options "-Os -march=z13" } */
+
+#include <assert.h>
+#include <stdint.h>
+
+__attribute__((noinline))
+void bar () {}
+
+__attribute__((noinline))
+__attribute__((optimize("O2")))
+void baf () {}
+
+int main ()
+{
+ bar ();
+ baf ();
+
+ void *g = &baf;
+
+ assert ( ((uintptr_t)g % 16) == 0);
+}