https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69355
--- Comment #18 from Martin Jambor <jamborm at gcc dot gnu.org> --- The reduced testcase does not fail for me for some reason, but the original one does. In any event, the problem is that an grp_unscalarized_data flag is zero even though evidently it should not be. That happens because of conditions which were added to ignore padding in case of total scalarization, which however misfired because the total scalarization was not successful (we do not scalarize when a scalar access has a smaller scalar access within it). The wrong grp_unscalarized_data value meant we removed original aggregate store even though we did not have scalar replacements for a part of it. I'll bootstrap the following patch to address this: diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 740542f..b0e737a 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -2421,7 +2421,7 @@ analyze_access_subtree (struct access *root, struct access *parent, if (covered_to < limit) hole = true; - if (scalar) + if (scalar || !allow_replacements) root->grp_total_scalarization = 0; }