On Wed, Jun 8, 2022 at 4:14 PM Eric Botcazou via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > > The fix is to ensure that we call expand_expr with EXPAND_MEMORY > > when processing the VAR_DECL's returned by get_inner_reference. > > > > This patch has been tested on x86_64-pc-linux-gnu with make bootstrap > > and make -k check (with no new failures), but also with > > --enable-languages="ada" where it allows the bootstrap to finish, > > and with no unexpected failures in the acats and gnat testsuites. > > Ok for mainline? > > Yes, thanks (modulo the nit in the ChangeLog).
+ /* If tem is a VAR_DECL, we need a memory reference. */ + enum expand_modifier tem_modifier = modifier; + if (tem_modifier == EXPAND_SUM) + tem_modifier = EXPAND_NORMAL; + if (TREE_CODE (tem) == VAR_DECL) + tem_modifier = EXPAND_MEMORY; that changes EXPAND_WRITE to EXPAND_MEMORY for VAR_DECL for example - what's 'modifier' in the problematic case? I do not understand how 'VAR_DECL' is special here btw. - it seems to be a condition making sure the new optimization doesn't trigger rather than a condition that will always require memory? Richard. > > 2022-06-08 Roger Sayle <ro...@nextmovesoftware.com> > > > > gcc/ChangeLog > > PR middle-end/105874 > > * gcc/expr.cc (expand_expr_real_1) <normal_inner_ref>: New local > > variable tem_modifier for calculating the expand_modifier enum to > > use for expanding tem. If tem is a VAR_DECL, use EXPAND_MEMORY. > > gcc/ prefix to be stripped > > -- > Eric Botcazou > >