Hi,

the following patch increases the default function alignment to 16
bytes.  This helps get rid of some unwanted performance effects.

I'm unsure whether or when it's necessary to implement
OVERRIDE_OPTIONS_AFTER_CHANGE.
Apparently ia64 did it to set flags that are reset when using
__attribute__((optimize)). i386 calls i386_default_align () and sets
various alignments only when the alignment value is unset but when is
e.g. global_options.x_str_align_functions actually unset except for the
very first call?

Trying simple examples like


 void foo () {};

 __attribute__((optimize("Os")))
 void bar () {};


I did not observe that the default alignment, once set, was reset anywhere.

Regards
 Robin

--

gcc/ChangeLog:

2018-07-11  Robin Dapp  <rd...@linux.ibm.com>

        * config/s390/s390.c (s390_default_align): Set default
        function alignment.
        (s390_override_options_after_change): New.
        (s390_option_override_internal): Call s390_default_align.
        (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): New.
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 8df195ddd78..eaeba89b321 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -15322,6 +15322,23 @@ s390_function_specific_restore (struct gcc_options *opts,
   opts->x_s390_cost_pointer = (long)processor_table[opts->x_s390_tune].cost;
 }
 
+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_optimize_size)
+    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,
@@ -15559,6 +15576,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);
@@ -16751,6 +16771,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

Reply via email to