https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93667
--- Comment #5 from Martin Jambor <jamborm at gcc dot gnu.org> --- It is easy to prevent the ICE with the following, which prevents total scalarization from happening. However, if someone marked a field with such an attribute, the encompassing structure perhaps should be optimized a much as we can? So I am thinking of adding a predicate bunch_of_empty_records_p which will return true for a type which only consists of records which only have field_decls which are other records but nothing else and still allow total scalarization of those. The easy fix is: --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -958,6 +958,9 @@ scalarizable_type_p (tree type, bool const_decl) if (type_contains_placeholder_p (type)) return false; + bool have_predecesor_field = false; + HOST_WIDE_INT prev_pos = 0; + switch (TREE_CODE (type)) { case RECORD_TYPE: @@ -966,6 +969,14 @@ scalarizable_type_p (tree type, bool const_decl) { tree ft = TREE_TYPE (fld); + HOST_WIDE_INT pos = int_bit_position (fld); + if (have_predecesor_field + && pos <= prev_pos) + return false; + + have_predecesor_field = true; + prev_pos = pos; + if (DECL_BIT_FIELD (fld)) return false;