public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Philipp Tomsich <ptomsich@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/vrull/heads/for-upstream)] Add new flag 'falign-arrays' Date: Fri, 18 Nov 2022 23:19:30 +0000 (GMT) [thread overview] Message-ID: <20221118231930.A0592384F6D5@sourceware.org> (raw) 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
next reply other threads:[~2022-11-18 23:19 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-18 23:19 Philipp Tomsich [this message] 2022-12-01 13:24 Philipp Tomsich
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=20221118231930.A0592384F6D5@sourceware.org \ --to=ptomsich@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).