From: rsandifo Date: Wed, 3 Jan 2018 07:17:46 +0000 (+0000) Subject: poly_int: expand_expr_real_2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b24cfb61ee08c14b5b08eeb9ec98fce2de1ba250;p=thirdparty%2Fgcc.git poly_int: expand_expr_real_2 This patch makes expand_expr_real_2 cope with polynomial mode sizes when handling conversions involving a union type. 2018-01-03 Richard Sandiford Alan Hayward David Sherwood gcc/ * expr.c (expand_expr_real_2): When handling conversions involving unions, apply tree_to_poly_uint64 to the TYPE_SIZE rather than multiplying int_size_in_bytes by BITS_PER_UNIT. Treat GET_MODE_BISIZE as a poly_uint64 too. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@256151 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e7901e52116e..6cef62278cea 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2018-01-03 Richard Sandiford + Alan Hayward + David Sherwood + + * expr.c (expand_expr_real_2): When handling conversions involving + unions, apply tree_to_poly_uint64 to the TYPE_SIZE rather than + multiplying int_size_in_bytes by BITS_PER_UNIT. Treat GET_MODE_BISIZE + as a poly_uint64 too. + 2018-01-03 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/expr.c b/gcc/expr.c index ab49c559a2b0..abab83136d3b 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -8424,11 +8424,14 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, && !TYPE_REVERSE_STORAGE_ORDER (type)); /* Store this field into a union of the proper type. */ + poly_uint64 op0_size + = tree_to_poly_uint64 (TYPE_SIZE (TREE_TYPE (treeop0))); + poly_uint64 union_size = GET_MODE_BITSIZE (mode); store_field (target, - MIN ((int_size_in_bytes (TREE_TYPE - (treeop0)) - * BITS_PER_UNIT), - (HOST_WIDE_INT) GET_MODE_BITSIZE (mode)), + /* The conversion must be constructed so that + we know at compile time how many bits + to preserve. */ + ordered_min (op0_size, union_size), 0, 0, 0, TYPE_MODE (valtype), treeop0, 0, false, false); }