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, 27 Jan 2023 02:25:43 +0000 (GMT) [thread overview] Message-ID: <20230127022543.6324E3858C00@sourceware.org> (raw) https://gcc.gnu.org/g:9258b638dbdecef19a55d530854d59e4fce3e21b commit 9258b638dbdecef19a55d530854d59e4fce3e21b Author: Alexandre Oliva <oliva@gnu.org> Date: Thu Jan 26 22:52:14 2023 -0300 turn -finline-memset-loops into -finline-stringops Diff: --- gcc/builtins.cc | 12 +++++++-- gcc/common.opt | 36 ++++++++++++++++++++++--- gcc/doc/invoke.texi | 20 ++++++++------ gcc/flag-types.h | 11 ++++++++ gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c | 2 +- 5 files changed, 67 insertions(+), 14 deletions(-) diff --git a/gcc/builtins.cc b/gcc/builtins.cc index 733fe17ede6..bf21fef699f 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; @@ -7427,7 +7427,15 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, && fcode != BUILT_IN_EXECVE && fcode != BUILT_IN_CLEAR_CACHE && !ALLOCA_FUNCTION_CODE_P (fcode) - && fcode != BUILT_IN_FREE) + && fcode != BUILT_IN_FREE + && (fcode != BUILT_IN_MEMSET + || (flag_inline_stringops & ILSOP_MEMSET)) + && (fcode != BUILT_IN_MEMCPY + || (flag_inline_stringops & ILSOP_MEMCPY)) + && (fcode != BUILT_IN_MEMMOVE + || (flag_inline_stringops & ILSOP_MEMMOVE)) + && (fcode != BUILT_IN_MEMCMP + || (flag_inline_stringops & ILSOP_MEMCMP))) return expand_call (exp, target, ignore); /* The built-in function expanders test for target == const0_rtx diff --git a/gcc/common.opt b/gcc/common.opt index 5d28f054241..ad85e8ca6ac 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1874,9 +1874,39 @@ 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 RejectNegative Enum(ilsop_fn) Var(flag_inline_stringops, ILSOP_ALL) Enum(ilsop_fn) Init(ILSOP_NONE) Optimization Undocumented + +fno-inline-stringops +Common RejectNegative Enum(ilsop_fn) Var(flag_inline_stringops, ILSOP_NONE) Enum(ilsop_fn) 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) + +; This is not part of any set. +; EnumValue +; Enum(ilsop_fn) String(none) Value(ILSOP_NONE) + +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) + +; This is not part of any set either. +; EnumValue +; Enum(ilsop_fn) String(all) Value(ILSOP_ALL) fcf-protection Common RejectNegative Alias(fcf-protection=,full) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 651307f315d..c695a8e641f 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -11964,14 +11964,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..a9d9eb166b6 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 = -1 +}; + /* 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-27 2:25 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-27 2:25 Alexandre Oliva [this message] -- strict thread matches above, loose matches on Subject: below -- 2023-01-27 5:58 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:12 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=20230127022543.6324E3858C00@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).