public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops Date: Fri, 20 Jan 2023 19:12:26 +0000 (GMT) [thread overview] Message-ID: <20230120191226.7B30B385841E@sourceware.org> (raw) https://gcc.gnu.org/g:c7df5b26086995f4f31c719dc81d5e0a1b9dbc01 commit c7df5b26086995f4f31c719dc81d5e0a1b9dbc01 Author: Alexandre Oliva <oliva@gnu.org> Date: Fri Jan 20 13:43:14 2023 -0300 turn -finline-memset-loops into -finline-stringops Diff: --- gcc/builtins.cc | 2 +- gcc/common.opt | 31 ++++++++++++++++++++++--- gcc/doc/invoke.texi | 20 +++++++++------- gcc/flag-types.h | 11 +++++++++ gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c | 2 +- 5 files changed, 53 insertions(+), 13 deletions(-) diff --git a/gcc/builtins.cc b/gcc/builtins.cc index 733fe17ede6..b7737678a7d 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -4373,7 +4373,7 @@ try_store_by_multiple_pieces (rtx to, rtx len, unsigned int ctz_len, || !can_store_by_pieces (xlenest, builtin_memset_read_str, &valc, align, true)) { - if (!flag_inline_memset_loops) + if (!(flag_inline_stringops & ILSOP_MEMSET)) return false; for (max_bits = orig_max_bits; diff --git a/gcc/common.opt b/gcc/common.opt index 5d28f054241..f617a0e6e9c 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1874,9 +1874,34 @@ finline-atomics Common Var(flag_inline_atomics) Init(1) Optimization Inline __atomic operations when a lock free instruction sequence is available. -finline-memset-loops -Common Var(flag_inline_memset_loops) Init(0) Optimization -Inline memset even if it requires loops. +finline-stringops +Common Enum(ilsop_fn) Var(flag_inline_stringops, ILSOP_ALL) Enum(ilsop_fn) Init(ILSOP_NONE) Optimization Undocumented + +finline-stringops= +Common Joined Var(flag_inline_stringops) EnumSet Enum(ilsop_fn) Optimization +-finline-stringops[=memcmp|memcpy|memmove|memset] +Expand supported mem/str operations inline, even if against optimization. + +Enum +Name(ilsop_fn) Type(enum ilsop_fn) UnknownError(unavailable stringop for inlining %qs) + +EnumValue +Enum(ilsop_fn) String(memcmp) Value(ILSOP_MEMCMP) Set(1) + +EnumValue +Enum(ilsop_fn) String(memcpy) Value(ILSOP_MEMCPY) Set(2) + +EnumValue +Enum(ilsop_fn) String(memmove) Value(ILSOP_MEMMOVE) Set(3) + +EnumValue +Enum(ilsop_fn) String(memset) Value(ILSOP_MEMSET) Set(4) + +; EnumValue +; Enum(ilsop_fn) String(all) Value(ILSOP_ALL) + +; EnumValue +; Enum(ilsop_fn) String(none) Value(ILSOP_NONE) fcf-protection Common RejectNegative Alias(fcf-protection=,full) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 8f8d52bbeef..4b5717c030b 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -11962,14 +11962,18 @@ in its own right. Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os}, but not @option{-Og}. -@item -finline-memset-loops -@opindex finline-memset-loops -Expand @code{memset} calls inline, even when the length is variable or -big enough as to require looping. This may enable the compiler to take -advantage of known alignment and length multipliers, but it will often -generate code that is less efficient than performant implementations of -@code{memset}, and grow code size so much that even a less performant -@code{memset} may run faster due to better use of the code cache. This +@item -finline-stringops[=@var{fn}] +@opindex finline-stringops +Expand memory and string operations (for now, only @code{memset}) +inline, even when the length is variable or big enough as to require +looping. This is most useful along with @option{-ffreestanding} and +@option{-fno-builtin}. + +In some circumstances, it enables the compiler to generate code that +takes advantage of known alignment and length multipliers, but even then +it may be less efficient than optimized runtime implementations, and +grow code size so much that even a less performant but shared +implementation runs faster due to better use of code caches. This option is disabled by default. @item -fearly-inlining diff --git a/gcc/flag-types.h b/gcc/flag-types.h index 78dbdbe90dd..0692d7c7464 100644 --- a/gcc/flag-types.h +++ b/gcc/flag-types.h @@ -432,6 +432,17 @@ enum gfc_convert }; +/* Inline String Operations functions. */ +enum ilsop_fn +{ + ILSOP_NONE = 0, + ILSOP_MEMSET = 1 << 0, + ILSOP_MEMCPY = 1 << 1, + ILSOP_MEMMOVE = 1 << 2, + ILSOP_MEMCMP = 1 << 3, + ILSOP_ALL = ~ILSOP_NONE +}; + /* Control-Flow Protection values. */ enum cf_protection_level { diff --git a/gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c b/gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c index 4de51df006e..8a2f5782b5a 100644 --- a/gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c +++ b/gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-finline-memset-loops -gno-record-gcc-switches -fno-lto" } */ +/* { dg-options "-finline-stringops -fno-lto" } */ void *zero (unsigned long long (*p)[32], int n) {
next reply other threads:[~2023-01-20 19:12 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-20 19:12 Alexandre Oliva [this message] -- strict thread matches above, loose matches on Subject: below -- 2023-01-27 5:58 Alexandre Oliva 2023-01-27 2:25 Alexandre Oliva 2023-01-27 1:57 Alexandre Oliva 2023-01-20 23:01 Alexandre Oliva 2023-01-20 19:17 Alexandre Oliva 2023-01-20 19:06 Alexandre Oliva 2023-01-20 18:57 Alexandre Oliva 2023-01-20 18:51 Alexandre Oliva 2023-01-20 18:50 Alexandre Oliva 2023-01-20 18:33 Alexandre Oliva 2023-01-20 18:28 Alexandre Oliva 2023-01-20 18:25 Alexandre Oliva 2023-01-20 18:20 Alexandre Oliva 2023-01-20 18:14 Alexandre Oliva 2023-01-20 18:12 Alexandre Oliva 2023-01-20 18:03 Alexandre Oliva 2023-01-20 17:55 Alexandre Oliva 2023-01-20 17:44 Alexandre Oliva 2023-01-20 16:58 Alexandre Oliva
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=20230120191226.7B30B385841E@sourceware.org \ --to=aoliva@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).