------- Comment #7 from rguenth at gcc dot gnu dot org 2008-12-05 13:05 ------- The following would make SRA only combine all of the struct or nothing. That avoids these messy situations:
Index: tree-sra.c =================================================================== --- tree-sra.c (revision 142469) +++ tree-sra.c (working copy) @@ -1695,7 +1695,10 @@ try_instantiate_multiple_fields (struct gcc_assert (~alchk < align); - /* Create the field group as a single variable. */ + /* Create the field group as a single variable if the group covers + the whole element. */ + if (size != TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (elt->element)))) + return f; /* We used to create a type for the mode above, but size turns to be out not of mode-size. As we need a matching type -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38271