public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/vrull/heads/for-upstream)] Add new flag 'falign-arrays'
@ 2022-12-01 13:24 Philipp Tomsich
0 siblings, 0 replies; 2+ messages in thread
From: Philipp Tomsich @ 2022-12-01 13:24 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:85b75e273cf56a9fcd114987eb9eff150fa3010d
commit 85b75e273cf56a9fcd114987eb9eff150fa3010d
Author: Christoph Müllner <christoph.muellner@vrull.eu>
Date: Fri Nov 11 17:28:42 2022 +0100
Add new flag 'falign-arrays'
This patch introduces a command line flag to define a minimum alignment
for arrays. This allows to enable more and/or more efficient expansions
of mem*/str* functions.
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Diff:
---
gcc/common.opt | 3 +++
gcc/doc/invoke.texi | 8 ++++++++
gcc/stor-layout.cc | 6 ++++++
3 files changed, 17 insertions(+)
diff --git a/gcc/common.opt b/gcc/common.opt
index 26e9d1cc4e7..e25226e05df 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1017,6 +1017,9 @@ faggressive-loop-optimizations
Common Var(flag_aggressive_loop_optimizations) Optimization Init(1)
Aggressively optimize loops using language constraints.
+falign-arrays
+Common Var(flag_align_arrays) Optimization Init(0)
+
falign-functions
Common Var(flag_align_functions) Optimization
Align the start of functions.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index a4695454158..150c1dd395f 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -525,6 +525,7 @@ Objective-C and Objective-C++ Dialects}.
@item Optimization Options
@xref{Optimize Options,,Options that Control Optimization}.
@gccoptlist{-faggressive-loop-optimizations @gol
+-falign-arrays @gol
-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
@@ -13386,6 +13387,13 @@ function boundary.
The @option{-fipa-strict-aliasing} option is enabled by default and is
effective only in combination with @option{-fstrict-aliasing}.
+@item -falign-arrays
+@opindex falign-arrays
+
+If this option is enabled, the compiler increases the minimum
+alignment of arrays to @code{STACK_BOUNDARY}, meaning the minimum
+alignment of the stack pointer is used.
+
@item -falign-functions
@itemx -falign-functions=@var{n}
@itemx -falign-functions=@var{n}:@var{m}
diff --git a/gcc/stor-layout.cc b/gcc/stor-layout.cc
index 88923c4136b..c7ed706cd58 100644
--- a/gcc/stor-layout.cc
+++ b/gcc/stor-layout.cc
@@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see
#include "attribs.h"
#include "debug.h"
#include "calls.h"
+#include "flags.h"
/* Data type for the expressions representing sizes of data types.
It is the first integer type laid out. */
@@ -2567,6 +2568,11 @@ layout_type (tree type)
using machine-dependent criteria if any. */
unsigned align = TYPE_ALIGN (element);
+
+ /* Apply minimum alignment for arrays. */
+ if (flag_align_arrays)
+ align = MAX (align, STACK_BOUNDARY);
+
if (TYPE_USER_ALIGN (type))
align = MAX (align, TYPE_ALIGN (type));
else
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gcc(refs/vendors/vrull/heads/for-upstream)] Add new flag 'falign-arrays'
@ 2022-11-18 23:19 Philipp Tomsich
0 siblings, 0 replies; 2+ messages in thread
From: Philipp Tomsich @ 2022-11-18 23:19 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:19954801e11a8733d190ea5a03e65bc3c5c05f4f
commit 19954801e11a8733d190ea5a03e65bc3c5c05f4f
Author: Christoph Müllner <christoph.muellner@vrull.eu>
Date: Fri Nov 11 17:28:42 2022 +0100
Add new flag 'falign-arrays'
This patch introduces a command line flag to define a minimum alignment
for arrays. This allows to enable more and/or more efficient expansions
of mem*/str* functions.
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Diff:
---
gcc/common.opt | 3 +++
gcc/doc/invoke.texi | 8 ++++++++
gcc/stor-layout.cc | 6 ++++++
3 files changed, 17 insertions(+)
diff --git a/gcc/common.opt b/gcc/common.opt
index 26e9d1cc4e7..e25226e05df 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1017,6 +1017,9 @@ faggressive-loop-optimizations
Common Var(flag_aggressive_loop_optimizations) Optimization Init(1)
Aggressively optimize loops using language constraints.
+falign-arrays
+Common Var(flag_align_arrays) Optimization Init(0)
+
falign-functions
Common Var(flag_align_functions) Optimization
Align the start of functions.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index a4695454158..150c1dd395f 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -525,6 +525,7 @@ Objective-C and Objective-C++ Dialects}.
@item Optimization Options
@xref{Optimize Options,,Options that Control Optimization}.
@gccoptlist{-faggressive-loop-optimizations @gol
+-falign-arrays @gol
-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
@@ -13386,6 +13387,13 @@ function boundary.
The @option{-fipa-strict-aliasing} option is enabled by default and is
effective only in combination with @option{-fstrict-aliasing}.
+@item -falign-arrays
+@opindex falign-arrays
+
+If this option is enabled, the compiler increases the minimum
+alignment of arrays to @code{STACK_BOUNDARY}, meaning the minimum
+alignment of the stack pointer is used.
+
@item -falign-functions
@itemx -falign-functions=@var{n}
@itemx -falign-functions=@var{n}:@var{m}
diff --git a/gcc/stor-layout.cc b/gcc/stor-layout.cc
index 88923c4136b..c7ed706cd58 100644
--- a/gcc/stor-layout.cc
+++ b/gcc/stor-layout.cc
@@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. If not see
#include "attribs.h"
#include "debug.h"
#include "calls.h"
+#include "flags.h"
/* Data type for the expressions representing sizes of data types.
It is the first integer type laid out. */
@@ -2567,6 +2568,11 @@ layout_type (tree type)
using machine-dependent criteria if any. */
unsigned align = TYPE_ALIGN (element);
+
+ /* Apply minimum alignment for arrays. */
+ if (flag_align_arrays)
+ align = MAX (align, STACK_BOUNDARY);
+
if (TYPE_USER_ALIGN (type))
align = MAX (align, TYPE_ALIGN (type));
else
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-01 13:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01 13:24 [gcc(refs/vendors/vrull/heads/for-upstream)] Add new flag 'falign-arrays' Philipp Tomsich
-- strict thread matches above, loose matches on Subject: below --
2022-11-18 23:19 Philipp Tomsich
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).