This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, S390] Increase function alignment to 16 bytes


On 07/11/2018 05:40 PM, Robin Dapp wrote:
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.

Hi.

Yes, it's how that should be done. That allows GCC to properly work
with per-function attributes (or corresponding #pragma).

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?

That said, it's probably wrongly implemented in ia64. But as it's legacy stuff,
I'm probably not planning to fix it.


Trying simple examples like


  void foo () {};

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


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

That should be set in  TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE.

Please skip '+      && !opts->x_optimize_size)'. I'm attaching patch that will
set opts->x_flag_align_functions to 0 for -Os. It's part of another batch
alignment patches I'm preparing.

Note that even when an alignment is set, we have
optimize_function_for_speed_p (cfun)) guards in assembly emission that
do not produce any alignment.

Martin



Regards
  Robin

--

gcc/ChangeLog:

2018-07-11  Robin Dapp  <rdapp@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.


>From ee6832050321149f9c0d180835658a684136ef58 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 12 Jul 2018 12:08:09 +0200
Subject: [PATCH] Do not enable OPT_falign_* for -Os.

gcc/ChangeLog:

2018-07-12  Martin Liska  <mliska@suse.cz>

	* opts.c: Do not enable OPT_falign_* for -Os.
---
 gcc/opts.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/opts.c b/gcc/opts.c
index 0625b15b27b..b8ae8756b4f 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -510,10 +510,10 @@ static const struct default_options default_options_table[] =
     { OPT_LEVELS_2_PLUS, OPT_fdevirtualize, NULL, 1 },
     { OPT_LEVELS_2_PLUS, OPT_fdevirtualize_speculatively, NULL, 1 },
     { OPT_LEVELS_2_PLUS, OPT_fipa_sra, NULL, 1 },
-    { OPT_LEVELS_2_PLUS, OPT_falign_loops, NULL, 1 },
-    { OPT_LEVELS_2_PLUS, OPT_falign_jumps, NULL, 1 },
-    { OPT_LEVELS_2_PLUS, OPT_falign_labels, NULL, 1 },
-    { OPT_LEVELS_2_PLUS, OPT_falign_functions, NULL, 1 },
+    { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_falign_loops, NULL, 1 },
+    { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_falign_jumps, NULL, 1 },
+    { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_falign_labels, NULL, 1 },
+    { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_falign_functions, NULL, 1 },
     { OPT_LEVELS_2_PLUS, OPT_ftree_tail_merge, NULL, 1 },
     { OPT_LEVELS_2_PLUS, OPT_fvect_cost_model_, NULL, VECT_COST_MODEL_CHEAP },
     { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_foptimize_strlen, NULL, 1 },
-- 
2.18.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]