public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 19:17 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 19:17 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2332a0da6d6455727cf6624e7f9e5211264258bd
commit 2332a0da6d6455727cf6624e7f9e5211264258bd
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 | 34 ++++++++++++++++++++++---
gcc/doc/invoke.texi | 20 +++++++++------
gcc/flag-types.h | 11 ++++++++
gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c | 2 +-
5 files changed, 56 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..42321ee0bd1 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1874,9 +1874,37 @@ 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)
+
+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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-27 5:58 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-27 5:58 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d94cf5ede8459185ba20df22c568de0620cf472a
commit d94cf5ede8459185ba20df22c568de0620cf472a
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..894ee99fd9a 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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-27 2:25 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-27 2:25 UTC (permalink / raw)
To: gcc-cvs
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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-27 1:57 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-27 1:57 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f84259ecadfc6842f091fa46a4b744afccd2a19f
commit f84259ecadfc6842f091fa46a4b744afccd2a19f
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 | 2 +-
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, 58 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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 23:01 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 23:01 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e0040ea65f4bc31d7ee62689353604dcd85d94f8
commit e0040ea65f4bc31d7ee62689353604dcd85d94f8
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 | 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, 58 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..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 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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 19:12 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 19:12 UTC (permalink / raw)
To: gcc-cvs
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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 19:06 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 19:06 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:81d7750a9a81bb1ead3484d2fbe0503bc485d3a2
commit 81d7750a9a81bb1ead3484d2fbe0503bc485d3a2
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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 18:57 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 18:57 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d0e8b90de346a67eb405f9efb7b3f70c0dc70fa7
commit d0e8b90de346a67eb405f9efb7b3f70c0dc70fa7
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..29d085db479 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 Alias(finline-stringops=,all,none)
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops) EnumSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization
+-finline-stringops[=all|memcmp|memcpy|memmove|memset|none]
+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(all) Value(ILSOP_ALL)
+
+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(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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 18:51 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 18:51 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9715ac911a067c67d0ca4dae6dbf73da7a87ec38
commit 9715ac911a067c67d0ca4dae6dbf73da7a87ec38
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..95f5811abe8 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 Alias(finline-stringops=,all,none)
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops) EnumSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization
+-finline-stringops[=all|memcmp|memcpy|memmove|memset|none]
+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(all) Value(ILSOP_ALL) Set(64)
+
+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(none) Value(ILSOP_NONE) Set(64)
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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 18:50 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 18:50 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:cd0f06c2184a4a7cf85f303e5e9026c83d693cc2
commit cd0f06c2184a4a7cf85f303e5e9026c83d693cc2
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..ebba4b9a525 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 Alias(finline-stringops=,all,none)
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops) EnumSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization
+-finline-stringops[=all|memcmp|memcpy|memmove|memset|none]
+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(all) Value(ILSOP_ALL) Set(0)
+
+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(none) Value(ILSOP_NONE) Set(0)
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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 18:33 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 18:33 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:601dfcd74769f609703d29e1f7b6d23aaf26c6b7
commit 601dfcd74769f609703d29e1f7b6d23aaf26c6b7
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..ebba4b9a525 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 Alias(finline-stringops=,all,none)
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops) EnumSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization
+-finline-stringops[=all|memcmp|memcpy|memmove|memset|none]
+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(all) Value(ILSOP_ALL) Set(0)
+
+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(none) Value(ILSOP_NONE) Set(0)
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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 18:28 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 18:28 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:265aa00499448efef7ad563d1c93f878ae223e9c
commit 265aa00499448efef7ad563d1c93f878ae223e9c
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..0eaaca6bfa7 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 RejectNegative Alias(finline-stringops=,all,none)
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops) EnumSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization
+-finline-stringops[=all|memcmp|memcpy|memmove|memset|none]
+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(all) Value(ILSOP_ALL) Set(-1)
+
+EnumValue
+Enum(ilsop_fn) String(memcmp) Value(ILSOP_MEMCMP) Set(0)
+
+EnumValue
+Enum(ilsop_fn) String(memcpy) Value(ILSOP_MEMCPY) Set(1)
+
+EnumValue
+Enum(ilsop_fn) String(memmove) Value(ILSOP_MEMMOVE) Set(2)
+
+EnumValue
+Enum(ilsop_fn) String(memset) Value(ILSOP_MEMSET) Set(3)
+
+EnumValue
+Enum(ilsop_fn) String(none) Value(ILSOP_NONE) Set(-1)
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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 18:25 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 18:25 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:32d4d57ac139eb0704d809b9d86099fd57736cd6
commit 32d4d57ac139eb0704d809b9d86099fd57736cd6
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..c2f24a0ae22 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 RejectNegative Alias(finline-stringops=,all,none)
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops, ILSOP_ALL) EnumSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization
+-finline-stringops[=all|memcmp|memcpy|memmove|memset|none]
+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(all) Value(ILSOP_ALL) Set(-1)
+
+EnumValue
+Enum(ilsop_fn) String(memcmp) Value(ILSOP_MEMCMP) Set(0)
+
+EnumValue
+Enum(ilsop_fn) String(memcpy) Value(ILSOP_MEMCPY) Set(1)
+
+EnumValue
+Enum(ilsop_fn) String(memmove) Value(ILSOP_MEMMOVE) Set(2)
+
+EnumValue
+Enum(ilsop_fn) String(memset) Value(ILSOP_MEMSET) Set(3)
+
+EnumValue
+Enum(ilsop_fn) String(none) Value(ILSOP_NONE) Set(-1)
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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 18:20 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 18:20 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:234e25395dbf56cc3da759a7d5885eea0e4688bd
commit 234e25395dbf56cc3da759a7d5885eea0e4688bd
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 | 34 ++++++++++++++++++++++---
gcc/doc/invoke.texi | 20 +++++++++------
gcc/flag-types.h | 11 ++++++++
gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c | 2 +-
5 files changed, 56 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..26bb1baec21 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1874,9 +1874,37 @@ 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 Alias(finline-stringops=,all)
+
+fno-inline-stringops
+Common RejectNegative Negative(finline-stringops=) Ignore
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops, ILSOP_ALL) EnumBitSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization Negative(fno-inline-stringops)
+-finline-stringops[=all|memcmp|memcpy|memmove|memset|none]
+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(all) Value(ILSOP_ALL)
+
+EnumValue
+Enum(ilsop_fn) String(memcmp) Value(ILSOP_MEMCMP)
+
+EnumValue
+Enum(ilsop_fn) String(memcpy) Value(ILSOP_MEMCPY)
+
+EnumValue
+Enum(ilsop_fn) String(memmove) Value(ILSOP_MEMMOVE)
+
+EnumValue
+Enum(ilsop_fn) String(memset) Value(ILSOP_MEMSET)
+
+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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 18:14 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 18:14 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:06562923bb249ab2f23d95d6f66f06603dc2d479
commit 06562923bb249ab2f23d95d6f66f06603dc2d479
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 | 34 ++++++++++++++++++++++---
gcc/doc/invoke.texi | 20 +++++++++------
gcc/flag-types.h | 11 ++++++++
gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c | 2 +-
5 files changed, 56 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..17933fbc001 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1874,9 +1874,37 @@ 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 Alias(finline-stringops=,all)
+
+fno-inline-stringops
+Common RejectNegative NegativeAlias(finline-stringops=)
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops, ILSOP_ALL) EnumBitSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization
+-finline-stringops[=all|memcmp|memcpy|memmove|memset|none]
+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(all) Value(ILSOP_ALL)
+
+EnumValue
+Enum(ilsop_fn) String(memcmp) Value(ILSOP_MEMCMP)
+
+EnumValue
+Enum(ilsop_fn) String(memcpy) Value(ILSOP_MEMCPY)
+
+EnumValue
+Enum(ilsop_fn) String(memmove) Value(ILSOP_MEMMOVE)
+
+EnumValue
+Enum(ilsop_fn) String(memset) Value(ILSOP_MEMSET)
+
+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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 18:12 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 18:12 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e9465e98faefc45f90daf25ddd42c145c4580df0
commit e9465e98faefc45f90daf25ddd42c145c4580df0
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 | 34 ++++++++++++++++++++++---
gcc/doc/invoke.texi | 20 +++++++++------
gcc/flag-types.h | 11 ++++++++
gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c | 2 +-
5 files changed, 56 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..89274461e8d 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1874,9 +1874,37 @@ 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 Alias(finline-stringops=,all,none)
+
+fno-inline-stringops
+Common RejectNegative Negative(finline-stringops=)
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops, ILSOP_ALL) EnumBitSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization Negative(fno-inline-stringops)
+-finline-stringops[=all|memcmp|memcpy|memmove|memset|none]
+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(all) Value(ILSOP_ALL)
+
+EnumValue
+Enum(ilsop_fn) String(memcmp) Value(ILSOP_MEMCMP)
+
+EnumValue
+Enum(ilsop_fn) String(memcpy) Value(ILSOP_MEMCPY)
+
+EnumValue
+Enum(ilsop_fn) String(memmove) Value(ILSOP_MEMMOVE)
+
+EnumValue
+Enum(ilsop_fn) String(memset) Value(ILSOP_MEMSET)
+
+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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 18:03 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 18:03 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d783f2f165f1858cca6ddf60bfcd4bab47436775
commit d783f2f165f1858cca6ddf60bfcd4bab47436775
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 | 34 ++++++++++++++++++++++---
gcc/doc/invoke.texi | 20 +++++++++------
gcc/flag-types.h | 11 ++++++++
gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c | 2 +-
5 files changed, 56 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..a69f58c146d 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1874,9 +1874,37 @@ 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 Alias(finline-stringops=,all,none)
+
+fno-inline-stringops
+Common RejectNegative Negative(finline-stringops=)
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops, ILSOP_ALL) EnumBitSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization
+-finline-stringops[=all|memcmp|memcpy|memmove|memset|none]
+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(all) Value(ILSOP_ALL)
+
+EnumValue
+Enum(ilsop_fn) String(memcmp) Value(ILSOP_MEMCMP)
+
+EnumValue
+Enum(ilsop_fn) String(memcpy) Value(ILSOP_MEMCPY)
+
+EnumValue
+Enum(ilsop_fn) String(memmove) Value(ILSOP_MEMMOVE)
+
+EnumValue
+Enum(ilsop_fn) String(memset) Value(ILSOP_MEMSET)
+
+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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 17:55 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 17:55 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:75910595dc5c7d4b3f0cfb34eb7761528027da69
commit 75910595dc5c7d4b3f0cfb34eb7761528027da69
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 | 34 ++++++++++++++++++++++---
gcc/doc/invoke.texi | 20 +++++++++------
gcc/flag-types.h | 11 ++++++++
gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c | 2 +-
5 files changed, 56 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..b01f77cffa5 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1874,9 +1874,37 @@ 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 Alias(finline-stringops=,all,none)
+
+finline-stringops=none
+Common RejectNegative Negative(finline-stringops=)
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops, ILSOP_ALL) EnumBitSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization
+-finline-stringops[=all|memcmp|memcpy|memmove|memset|none]
+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(all) Value(ILSOP_ALL)
+
+EnumValue
+Enum(ilsop_fn) String(memcmp) Value(ILSOP_MEMCMP)
+
+EnumValue
+Enum(ilsop_fn) String(memcpy) Value(ILSOP_MEMCPY)
+
+EnumValue
+Enum(ilsop_fn) String(memmove) Value(ILSOP_MEMMOVE)
+
+EnumValue
+Enum(ilsop_fn) String(memset) Value(ILSOP_MEMSET)
+
+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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 17:44 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 17:44 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0c510a1e1445fadc5050c9045660452939f4288d
commit 0c510a1e1445fadc5050c9045660452939f4288d
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..90e82870969 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 Alias(finline-stringops=,all,none)
+
+finline-stringops=
+Common RejectNegative Joined Var(flag_inline_stringops, ILSOP_ALL) EnumBitSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization
+-finline-stringops[=all|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(all) Value(ILSOP_ALL)
+
+EnumValue
+Enum(ilsop_fn) String(memcmp) Value(ILSOP_MEMCMP)
+
+EnumValue
+Enum(ilsop_fn) String(memcpy) Value(ILSOP_MEMCPY)
+
+EnumValue
+Enum(ilsop_fn) String(memmove) Value(ILSOP_MEMMOVE)
+
+EnumValue
+Enum(ilsop_fn) String(memset) Value(ILSOP_MEMSET)
+
+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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
* [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops
@ 2023-01-20 16:58 Alexandre Oliva
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Oliva @ 2023-01-20 16:58 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3280e71f13d92869c0f750670b3734898f333e20
commit 3280e71f13d92869c0f750670b3734898f333e20
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 | 28 ++++++++++++++++++++++---
gcc/doc/invoke.texi | 20 +++++++++++-------
gcc/flag-types.h | 11 ++++++++++
gcc/testsuite/gcc.dg/torture/inline-mem-set-1.c | 2 +-
5 files changed, 50 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..5708823ec7c 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1874,9 +1874,31 @@ 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 JoinedOrMissing Var(flag_inline_stringops, ILSOP_ALL) EnumBitSet Enum(ilsop_fn) Init(ILSOP_NONE) Optimization
+-finline-stringops[=all|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(all) Value(ILSOP_ALL)
+
+EnumValue
+Enum(ilsop_fn) String(memcmp) Value(ILSOP_MEMCMP)
+
+EnumValue
+Enum(ilsop_fn) String(memcpy) Value(ILSOP_MEMCPY)
+
+EnumValue
+Enum(ilsop_fn) String(memmove) Value(ILSOP_MEMMOVE)
+
+EnumValue
+Enum(ilsop_fn) String(memset) Value(ILSOP_MEMSET)
+
+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..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)
{
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2023-01-27 5:58 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-20 19:17 [gcc(refs/users/aoliva/heads/testme)] turn -finline-memset-loops into -finline-stringops Alexandre Oliva
-- 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: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
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).