diff mbox series

[088/nnn] poly_int: expand_expr_real_2

Message ID 878tg1g42o.fsf@linaro.org
State New
Headers show
Series [088/nnn] poly_int: expand_expr_real_2 | expand

Commit Message

Richard Sandiford Oct. 23, 2017, 5:35 p.m. UTC
This patch makes expand_expr_real_2 cope with polynomial mode sizes
when handling conversions involving a union type.


2017-10-23  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

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.

Comments

Jeff Law Nov. 28, 2017, 8:34 a.m. UTC | #1
On 10/23/2017 11:35 AM, Richard Sandiford wrote:
> This patch makes expand_expr_real_2 cope with polynomial mode sizes

> when handling conversions involving a union type.

> 

> 

> 2017-10-23  Richard Sandiford  <richard.sandiford@linaro.org>

> 	    Alan Hayward  <alan.hayward@arm.com>

> 	    David Sherwood  <david.sherwood@arm.com>

> 

> 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.

OK.
jeff
diff mbox series

Patch

Index: gcc/expr.c
===================================================================
--- gcc/expr.c	2017-10-23 17:25:30.704136008 +0100
+++ gcc/expr.c	2017-10-23 17:25:34.105013764 +0100
@@ -8354,11 +8354,14 @@  #define REDUCE_BIT_FIELD(expr)	(reduce_b
 			  && !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);
 	    }