https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120702
--- Comment #12 from Visda <Visda.vokhshoori at microchip dot com> --- (In reply to [email protected] from comment #11) > On Tue, 5 May 2026, Visda.vokhshoori at microchip dot com wrote: > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120702 > > > > --- Comment #10 from Visda <Visda.vokhshoori at microchip dot com> --- > > adding this amount of code in fold_ctor_reference () circumvents forward > > propagating large, (>128 characters), string literals. > > > > --- a/gcc/gimple-fold.cc > > +++ b/gcc/gimple-fold.cc > > @@ -8122,7 +8122,9 @@ fold_ctor_reference (tree type, tree ctor, const > > poly_uint64 &poly_offset, > > /* We found the field with exact match. */ > > if (type > > && useless_type_conversion_p (type, TREE_TYPE (ctor)) > > - && known_eq (poly_offset, 0U)) > > + && known_eq (poly_offset, 0U) > > + && (TREE_CODE (ctor) != STRING_CST > > + || TREE_STRING_LENGTH (ctor) <= MAX_BITSIZE_MODE_ANY_MODE / > > BITS_PER_UNIT)) > > return canonicalize_constructor_val (unshare_expr (ctor), from_decl); > > > > > > looking for feedback. thanks. > > I have posted a patch for review that does the following instead > (it's a better place to gate the transform) > > diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc > index 4ec6cc65e3a..8f9119f2469 100644 > --- a/gcc/gimple-fold.cc > +++ b/gcc/gimple-fold.cc > @@ -306,6 +306,11 @@ maybe_fold_reference (tree expr) > { > tree result = NULL_TREE; > > + /* Avoid expensive fold_const_aggregate_ref early on aggregate loads > + and esp. replacing STRING_CSTs inline. */ > + if (!is_gimple_reg_type (TREE_TYPE (expr))) > + return NULL_TREE; > + > if ((TREE_CODE (expr) == VIEW_CONVERT_EXPR > || TREE_CODE (expr) == REALPART_EXPR > || TREE_CODE (expr) == IMAGPART_EXPR) thanks for letting me know.
