diff options
Diffstat (limited to 'gcc/tree-sra.c')
-rw-r--r-- | gcc/tree-sra.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index c7f4174..28eba43 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -1421,12 +1421,16 @@ build_ref_for_model (location_t loc, tree base, HOST_WIDE_INT offset, { if (TREE_CODE (model->expr) == COMPONENT_REF) { - tree t, exp_type; - offset -= int_bit_position (TREE_OPERAND (model->expr, 1)); + tree t, exp_type, fld = TREE_OPERAND (model->expr, 1); + tree cr_offset = component_ref_field_offset (model->expr); + + gcc_assert (cr_offset && host_integerp (cr_offset, 1)); + offset -= TREE_INT_CST_LOW (cr_offset) * BITS_PER_UNIT; + offset -= TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (fld)); exp_type = TREE_TYPE (TREE_OPERAND (model->expr, 0)); t = build_ref_for_offset (loc, base, offset, exp_type, gsi, insert_after); - return fold_build3_loc (loc, COMPONENT_REF, model->type, t, - TREE_OPERAND (model->expr, 1), NULL_TREE); + return fold_build3_loc (loc, COMPONENT_REF, model->type, t, fld, + TREE_OPERAND (model->expr, 2)); } else return build_ref_for_offset (loc, base, offset, model->type, |