https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113727
--- Comment #22 from Richard Biener <rguenth at gcc dot gnu.org> --- Handling LHS sra_handled_bf_read_p the same as RHS also fixes the issue, we then detect the partial overlap of the accesses without looking at grp_partial_lhs. I wonder if we run into the same issue for REAL/IMAGPART_EXPR on the LHS when we have both _Complex and component accesses mixed. So alternative patch: diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc index f8e71ec48b9..8e9c2e3d343 100644 --- a/gcc/tree-sra.cc +++ b/gcc/tree-sra.cc @@ -1161,7 +1161,7 @@ build_access_from_expr_1 (tree expr, gimple *stmt, bool write) bool partial_ref; if ((TREE_CODE (expr) == BIT_FIELD_REF - && (write || !sra_handled_bf_read_p (expr))) + && !sra_handled_bf_read_p (expr)) || TREE_CODE (expr) == IMAGPART_EXPR || TREE_CODE (expr) == REALPART_EXPR) { @@ -3973,7 +3980,7 @@ sra_modify_expr (tree *expr, bool write, gimple_stmt_iterator *stmt_gsi, bool partial_cplx_access = false; if (TREE_CODE (*expr) == BIT_FIELD_REF - && (write || !sra_handled_bf_read_p (*expr))) + && !sra_handled_bf_read_p (*expr)) { bfr = *expr; expr = &TREE_OPERAND (*expr, 0); @@ -4517,7 +4524,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi) if (TREE_CODE (rhs) == REALPART_EXPR || TREE_CODE (lhs) == REALPART_EXPR || TREE_CODE (rhs) == IMAGPART_EXPR || TREE_CODE (lhs) == IMAGPART_EXPR || (TREE_CODE (rhs) == BIT_FIELD_REF && !sra_handled_bf_read_p (rhs)) - || TREE_CODE (lhs) == BIT_FIELD_REF) + || (TREE_CODE (lhs) == BIT_FIELD_REF && !sra_handled_bf_read_p (lhs))) { modify_this_stmt = sra_modify_expr (gimple_assign_rhs1_ptr (stmt), false, gsi, gsi);