public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-120] c++: optimize reshape_init
@ 2022-05-04 20:02 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-05-04 20:02 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c8df7208864d863f58da55d42ff82663059930b1
commit r13-120-gc8df7208864d863f58da55d42ff82663059930b1
Author: Jason Merrill <jason@redhat.com>
Date: Mon Mar 21 09:58:28 2022 -0400
c++: optimize reshape_init
If the index of a constructor_elt is a FIELD_DECL, the CONSTRUCTOR is
already reshaped, so we can save time and memory by returning immediately.
gcc/cp/ChangeLog:
* decl.cc (reshape_init): Shortcut already-reshaped init.
(reshape_init_class): Assert not getting one here.
Diff:
---
gcc/cp/decl.cc | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index c9110db796a..0fa758ff214 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -6631,7 +6631,9 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p,
if (TREE_CODE (d->cur->index) == FIELD_DECL)
{
- /* We already reshaped this. */
+ /* We already reshaped this; we should have returned early from
+ reshape_init. */
+ gcc_checking_assert (false);
if (field != d->cur->index)
{
if (tree id = DECL_NAME (d->cur->index))
@@ -7068,6 +7070,10 @@ reshape_init (tree type, tree init, tsubst_flags_t complain)
if (vec_safe_is_empty (v))
return init;
+ if ((*v)[0].index && TREE_CODE ((*v)[0].index) == FIELD_DECL)
+ /* Already reshaped. */
+ return init;
+
/* Brace elision is not performed for a CONSTRUCTOR representing
parenthesized aggregate initialization. */
if (CONSTRUCTOR_IS_PAREN_INIT (init))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-04 20:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-04 20:02 [gcc r13-120] c++: optimize reshape_init Jason Merrill
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).