public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9329] x86: Make stringop_algs::stringop_strategy ctor constexpr [PR100246]
@ 2021-11-29 8:49 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-11-29 8:49 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:04d786a7add8f824af3b0c0d29884770810f7001
commit r11-9329-g04d786a7add8f824af3b0c0d29884770810f7001
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Nov 5 16:39:14 2021 +0100
x86: Make stringop_algs::stringop_strategy ctor constexpr [PR100246]
> Several older compilers fail to build modern GCC because of missing
> or incomplete C++11 support.
>
> * config/i386/i386.h (struct stringop_algs): Define a CTOR for
> this type.
Unfortunately, as mentioned in my
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583289.html
mail, without the new dyninit pass this causes dynamic initialization of
many variables, 6.5KB _GLOBAL__sub_I_* on x86_64 and 12.5KB on i686.
The following patch makes the ctor constexpr so that already the FE
is able to statically initialize all those.
I have tested on godbolt a reduced testcase without a constructor,
with constructor and with constexpr constructor.
clang before 3.3 is unhappy about all the 3 cases, clang 3.3 and 3.4
is ok with ctor and ctor with constexpr and optimizes it into static
initialization, clang 3.5+ is ok with all 3 versions and optimizes,
gcc 4.8 and 5+ is ok with all 3 versions and no ctor and ctor with constexpr
is optimized, gcc 4.9 is unhappy about the no ctor case and happy with the
other two.
2021-11-05 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/100246
* config/i386/i386.h
(stringop_algs::stringop_strategy::stringop_strategy): Make the ctor
constexpr.
(cherry picked from commit 858d7ee1a0cd97c01d844ea73ab81918da738344)
Diff:
---
gcc/config/i386/i386.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 73e118900f7..6fc1bf350d5 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -258,8 +258,9 @@ struct stringop_algs
this issue. Since this header is used by code compiled with the C
compiler we must guard the addition. */
#ifdef __cplusplus
- stringop_strategy(int _max = -1, enum stringop_alg _alg = libcall,
- int _noalign = false)
+ constexpr
+ stringop_strategy (int _max = -1, enum stringop_alg _alg = libcall,
+ int _noalign = false)
: max (_max), alg (_alg), noalign (_noalign) {}
#endif
const int max;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-11-29 8:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 8:49 [gcc r11-9329] x86: Make stringop_algs::stringop_strategy ctor constexpr [PR100246] Jakub Jelinek
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).