diff mbox series

Protect tree_to_shwi call in unmodified_param_1

Message ID mpto914c7km.fsf@arm.com
State New
Headers show
Series Protect tree_to_shwi call in unmodified_param_1 | expand

Commit Message

Richard Sandiford Aug. 5, 2019, 8:58 a.m. UTC
unmodified_param_1 used tree_to_shwi without first checking
tree_fits_shwi_p.  This is needed by the SVE ACLE support and
is hard to test independently.

Tested on aarch64-linux-gnu, armeb-eabi and x86_64-linux-gnu.
OK to install?

Richard


2019-08-05  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* ipa-fnsummary.c (unmodified_parm_1): Test tree_fits_shwi_p
	before calling to tree_to_shwi.

Comments

Richard Biener Aug. 5, 2019, 12:08 p.m. UTC | #1
On Mon, Aug 5, 2019 at 10:58 AM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> unmodified_param_1 used tree_to_shwi without first checking
> tree_fits_shwi_p.  This is needed by the SVE ACLE support and
> is hard to test independently.
>
> Tested on aarch64-linux-gnu, armeb-eabi and x86_64-linux-gnu.
> OK to install?

Hmm, a better fix would be to use poly_X for *size_p.  There are also
quite a number of callers with NULL size_p which you unduly
pessimize for SVE.

So, move the check to the if (size_p) case and add a FIXME
about SVE regs and poly_*?

OK with that.

Richard.

> Richard
>
>
> 2019-08-05  Richard Sandiford  <richard.sandiford@arm.com>
>
> gcc/
>         * ipa-fnsummary.c (unmodified_parm_1): Test tree_fits_shwi_p
>         before calling to tree_to_shwi.
>
> Index: gcc/ipa-fnsummary.c
> ===================================================================
> --- gcc/ipa-fnsummary.c 2019-07-16 09:11:50.509067138 +0100
> +++ gcc/ipa-fnsummary.c 2019-08-05 09:57:28.553617299 +0100
> @@ -927,7 +927,8 @@ unmodified_parm_1 (ipa_func_body_info *f
>    /* SSA_NAME referring to parm default def?  */
>    if (TREE_CODE (op) == SSA_NAME
>        && SSA_NAME_IS_DEFAULT_DEF (op)
> -      && TREE_CODE (SSA_NAME_VAR (op)) == PARM_DECL)
> +      && TREE_CODE (SSA_NAME_VAR (op)) == PARM_DECL
> +      && tree_fits_shwi_p (TYPE_SIZE (TREE_TYPE (op))))
>      {
>        if (size_p)
>         *size_p = tree_to_shwi (TYPE_SIZE (TREE_TYPE (op)));
Richard Sandiford Aug. 6, 2019, 2:48 p.m. UTC | #2
Richard Biener <richard.guenther@gmail.com> writes:
> On Mon, Aug 5, 2019 at 10:58 AM Richard Sandiford
> <richard.sandiford@arm.com> wrote:
>>
>> unmodified_param_1 used tree_to_shwi without first checking
>> tree_fits_shwi_p.  This is needed by the SVE ACLE support and
>> is hard to test independently.
>>
>> Tested on aarch64-linux-gnu, armeb-eabi and x86_64-linux-gnu.
>> OK to install?
>
> Hmm, a better fix would be to use poly_X for *size_p.  There are also
> quite a number of callers with NULL size_p which you unduly
> pessimize for SVE.

OK, you guilt-tripped me into doing it properly. :-)  How does this look?

Tested as before.

Richard


2019-08-06  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* data-streamer.h (streamer_write_poly_uint64): Declare.
	(streamer_read_poly_uint64): Likewise.
	* data-streamer-in.c (streamer_read_poly_uint64): New function.
	* data-streamer-out.c (streamer_write_poly_uint64): Likewise.
	* ipa-predicate.h (condition::size): Turn into a poly_int64.
	(add_condition): Take a poly_int64 size.
	* ipa-predicate.c (add_condition): Likewise.
	* ipa-prop.h (ipa_load_from_parm_agg): Take a poly_int64 size pointer.
	* ipa-prop.c (ipa_load_from_parm_agg): Likewise.
	(ipcp_modif_dom_walker::before_dom_children): Update accordingly.
	* ipa-fnsummary.c (evaluate_conditions_for_known_args): Handle
	condition::size as a poly_int64.
	(unmodified_parm_1): Take a poly_int64 size pointer.
	(unmodified_parm): Likewise.
	(unmodified_parm_or_parm_agg_item): Likewise.
	(set_cond_stmt_execution_predicate): Update accordingly.
	(set_switch_stmt_execution_predicate): Likewise.
	(will_be_nonconstant_expr_predicate): Likewise.
	(will_be_nonconstant_predicate): Likewise.
	(inline_read_section): Stream condition::size as a poly_int.
	(ipa_fn_summary_write): Likewise.

Index: gcc/data-streamer.h
===================================================================
--- gcc/data-streamer.h	2019-07-10 19:41:26.375898187 +0100
+++ gcc/data-streamer.h	2019-08-06 15:45:32.908297910 +0100
@@ -53,6 +53,7 @@ HOST_WIDE_INT bp_unpack_var_len_int (str
 void streamer_write_zero (struct output_block *);
 void streamer_write_uhwi (struct output_block *, unsigned HOST_WIDE_INT);
 void streamer_write_hwi (struct output_block *, HOST_WIDE_INT);
+void streamer_write_poly_uint64 (struct output_block *, poly_uint64);
 void streamer_write_gcov_count (struct output_block *, gcov_type);
 void streamer_write_string (struct output_block *, struct lto_output_stream *,
 			    const char *, bool);
@@ -82,6 +83,7 @@ const char *bp_unpack_indexed_string (cl
 const char *bp_unpack_string (class data_in *, struct bitpack_d *);
 unsigned HOST_WIDE_INT streamer_read_uhwi (class lto_input_block *);
 HOST_WIDE_INT streamer_read_hwi (class lto_input_block *);
+poly_uint64 streamer_read_poly_uint64 (class lto_input_block *);
 gcov_type streamer_read_gcov_count (class lto_input_block *);
 wide_int streamer_read_wide_int (class lto_input_block *);
 widest_int streamer_read_widest_int (class lto_input_block *);
Index: gcc/data-streamer-in.c
===================================================================
--- gcc/data-streamer-in.c	2019-07-10 19:41:20.147948065 +0100
+++ gcc/data-streamer-in.c	2019-08-06 15:45:32.908297910 +0100
@@ -175,6 +175,17 @@ streamer_read_hwi (class lto_input_block
     }
 }
 
+/* Read a poly_uint64 from IB.  */
+
+poly_uint64
+streamer_read_poly_uint64 (class lto_input_block *ib)
+{
+  poly_uint64 res;
+  for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
+    res.coeffs[i] = streamer_read_uhwi (ib);
+  return res;
+}
+
 /* Read gcov_type value from IB.  */
 
 gcov_type
Index: gcc/data-streamer-out.c
===================================================================
--- gcc/data-streamer-out.c	2019-03-08 18:14:27.285004225 +0000
+++ gcc/data-streamer-out.c	2019-08-06 15:45:32.908297910 +0100
@@ -220,6 +220,15 @@ streamer_write_hwi (struct output_block
   streamer_write_hwi_stream (ob->main_stream, work);
 }
 
+/* Write a poly_uint64 value WORK to OB->main_stream.  */
+
+void
+streamer_write_poly_uint64 (struct output_block *ob, poly_uint64 work)
+{
+  for (int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
+    streamer_write_uhwi_stream (ob->main_stream, work.coeffs[i]);
+}
+
 /* Write a gcov counter value WORK to OB->main_stream.  */
 
 void
Index: gcc/ipa-predicate.h
===================================================================
--- gcc/ipa-predicate.h	2019-07-10 19:41:27.163891877 +0100
+++ gcc/ipa-predicate.h	2019-08-06 15:45:32.908297910 +0100
@@ -31,7 +31,7 @@ struct GTY(()) condition
      loaded.  */
   HOST_WIDE_INT offset;
   /* Size of the access reading the data (or the PARM_DECL SSA_NAME).  */
-  HOST_WIDE_INT size;
+  poly_int64 size;
   tree val;
   int operand_num;
   ENUM_BITFIELD(tree_code) code : 16;
@@ -228,5 +228,5 @@ typedef uint32_t clause_t;
 
 void dump_condition (FILE *f, conditions conditions, int cond);
 predicate add_condition (class ipa_fn_summary *summary, int operand_num,
-			 HOST_WIDE_INT size, struct agg_position_info *aggpos,
+			 poly_int64 size, struct agg_position_info *aggpos,
 			 enum tree_code code, tree val);
Index: gcc/ipa-predicate.c
===================================================================
--- gcc/ipa-predicate.c	2019-07-10 19:41:27.159891908 +0100
+++ gcc/ipa-predicate.c	2019-08-06 15:45:32.908297910 +0100
@@ -523,7 +523,7 @@ predicate::stream_out (struct output_blo
 
 predicate
 add_condition (class ipa_fn_summary *summary, int operand_num,
-	       HOST_WIDE_INT size, struct agg_position_info *aggpos,
+	       poly_int64 size, struct agg_position_info *aggpos,
 	       enum tree_code code, tree val)
 {
   int i;
@@ -549,7 +549,7 @@ add_condition (class ipa_fn_summary *sum
   for (i = 0; vec_safe_iterate (summary->conds, i, &c); i++)
     {
       if (c->operand_num == operand_num
-	  && c->size == size
+	  && maybe_ne (c->size, size)
 	  && c->code == code
 	  && c->val == val
 	  && c->agg_contents == agg_contents
Index: gcc/ipa-prop.h
===================================================================
--- gcc/ipa-prop.h	2019-07-10 19:41:27.151891973 +0100
+++ gcc/ipa-prop.h	2019-08-06 15:45:32.912297882 +0100
@@ -763,7 +763,7 @@ tree ipa_find_agg_cst_for_param (struct
 bool ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
 			     vec<ipa_param_descriptor, va_gc> *descriptors,
 			     gimple *stmt, tree op, int *index_p,
-			     HOST_WIDE_INT *offset_p, HOST_WIDE_INT *size_p,
+			     HOST_WIDE_INT *offset_p, poly_int64 *size_p,
 			     bool *by_ref, bool *guaranteed_unmodified = NULL);
 
 /* Debugging interface.  */
Index: gcc/ipa-prop.c
===================================================================
--- gcc/ipa-prop.c	2019-07-10 19:41:27.151891973 +0100
+++ gcc/ipa-prop.c	2019-08-06 15:45:32.912297882 +0100
@@ -1059,7 +1059,7 @@ parm_ref_data_pass_through_p (struct ipa
 ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
 			vec<ipa_param_descriptor, va_gc> *descriptors,
 			gimple *stmt, tree op, int *index_p,
-			HOST_WIDE_INT *offset_p, HOST_WIDE_INT *size_p,
+			HOST_WIDE_INT *offset_p, poly_int64 *size_p,
 			bool *by_ref_p, bool *guaranteed_unmodified)
 {
   int index;
@@ -4917,7 +4917,8 @@ ipcp_modif_dom_walker::before_dom_childr
       struct ipa_agg_replacement_value *v;
       gimple *stmt = gsi_stmt (gsi);
       tree rhs, val, t;
-      HOST_WIDE_INT offset, size;
+      HOST_WIDE_INT offset;
+      poly_int64 size;
       int index;
       bool by_ref, vce;
 
@@ -4952,7 +4953,8 @@ ipcp_modif_dom_walker::before_dom_childr
 	  break;
       if (!v
 	  || v->by_ref != by_ref
-	  || tree_to_shwi (TYPE_SIZE (TREE_TYPE (v->value))) != size)
+	  || maybe_ne (tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (v->value))),
+		       size))
 	continue;
 
       gcc_checking_assert (is_gimple_ip_invariant (v->value));
Index: gcc/ipa-fnsummary.c
===================================================================
--- gcc/ipa-fnsummary.c	2019-08-05 17:46:25.000000000 +0100
+++ gcc/ipa-fnsummary.c	2019-08-06 15:45:32.908297910 +0100
@@ -382,7 +382,7 @@ evaluate_conditions_for_known_args (stru
 	  continue;
 	}
 
-      if (tree_to_shwi (TYPE_SIZE (TREE_TYPE (val))) != c->size)
+      if (maybe_ne (tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (val))), c->size))
 	{
 	  clause |= 1 << (i + predicate::first_dynamic_condition);
 	  nonspec_clause |= 1 << (i + predicate::first_dynamic_condition);
@@ -922,7 +922,7 @@ mark_modified (ao_ref *ao ATTRIBUTE_UNUS
 
 static tree
 unmodified_parm_1 (ipa_func_body_info *fbi, gimple *stmt, tree op,
-		   HOST_WIDE_INT *size_p)
+		   poly_int64 *size_p)
 {
   /* SSA_NAME referring to parm default def?  */
   if (TREE_CODE (op) == SSA_NAME
@@ -930,7 +930,7 @@ unmodified_parm_1 (ipa_func_body_info *f
       && TREE_CODE (SSA_NAME_VAR (op)) == PARM_DECL)
     {
       if (size_p)
-	*size_p = tree_to_shwi (TYPE_SIZE (TREE_TYPE (op)));
+	*size_p = tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (op)));
       return SSA_NAME_VAR (op);
     }
   /* Non-SSA parm reference?  */
@@ -951,7 +951,7 @@ unmodified_parm_1 (ipa_func_body_info *f
       if (!modified)
 	{
 	  if (size_p)
-	    *size_p = tree_to_shwi (TYPE_SIZE (TREE_TYPE (op)));
+	    *size_p = tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (op)));
 	  return op;
 	}
     }
@@ -965,7 +965,7 @@ unmodified_parm_1 (ipa_func_body_info *f
 
 static tree
 unmodified_parm (ipa_func_body_info *fbi, gimple *stmt, tree op,
-		 HOST_WIDE_INT *size_p)
+		 poly_int64 *size_p)
 {
   tree res = unmodified_parm_1 (fbi, stmt, op, size_p);
   if (res)
@@ -990,7 +990,7 @@ unmodified_parm (ipa_func_body_info *fbi
 static bool
 unmodified_parm_or_parm_agg_item (struct ipa_func_body_info *fbi,
 				  gimple *stmt, tree op, int *index_p,
-				  HOST_WIDE_INT *size_p,
+				  poly_int64 *size_p,
 				  struct agg_position_info *aggpos)
 {
   tree res = unmodified_parm_1 (fbi, stmt, op, size_p);
@@ -1169,7 +1169,7 @@ set_cond_stmt_execution_predicate (struc
   gimple *last;
   tree op;
   int index;
-  HOST_WIDE_INT size;
+  poly_int64 size;
   struct agg_position_info aggpos;
   enum tree_code code, inverted_code;
   edge e;
@@ -1254,7 +1254,7 @@ set_switch_stmt_execution_predicate (str
   gimple *lastg;
   tree op;
   int index;
-  HOST_WIDE_INT size;
+  poly_int64 size;
   struct agg_position_info aggpos;
   edge e;
   edge_iterator ei;
@@ -1393,7 +1393,7 @@ will_be_nonconstant_expr_predicate (ipa_
 {
   tree parm;
   int index;
-  HOST_WIDE_INT size;
+  poly_int64 size;
 
   while (UNARY_CLASS_P (expr))
     expr = TREE_OPERAND (expr, 0);
@@ -1468,7 +1468,7 @@ will_be_nonconstant_predicate (struct ip
   predicate op_non_const;
   bool is_load;
   int base_index;
-  HOST_WIDE_INT size;
+  poly_int64 size;
   struct agg_position_info aggpos;
 
   /* What statments might be optimized away
@@ -1524,7 +1524,7 @@ will_be_nonconstant_predicate (struct ip
     op_non_const = false;
   FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE)
     {
-      HOST_WIDE_INT size;
+      poly_int64 size;
       tree parm = unmodified_parm (fbi, stmt, use, &size);
       int index;
 
@@ -3292,7 +3292,7 @@ inline_read_section (struct lto_file_dec
 	{
 	  struct condition c;
 	  c.operand_num = streamer_read_uhwi (&ib);
-	  c.size = streamer_read_uhwi (&ib);
+	  c.size = streamer_read_poly_uint64 (&ib);
 	  c.code = (enum tree_code) streamer_read_uhwi (&ib);
 	  c.val = stream_read_tree (&ib, data_in);
 	  bp = streamer_read_bitpack (&ib);
@@ -3446,7 +3446,7 @@ ipa_fn_summary_write (void)
 	  for (i = 0; vec_safe_iterate (info->conds, i, &c); i++)
 	    {
 	      streamer_write_uhwi (ob, c->operand_num);
-	      streamer_write_uhwi (ob, c->size);
+	      streamer_write_poly_uint64 (ob, c->size);
 	      streamer_write_uhwi (ob, c->code);
 	      stream_write_tree (ob, c->val, true);
 	      bp = bitpack_create (ob->main_stream);
Richard Biener Aug. 7, 2019, 9:52 a.m. UTC | #3
On Tue, Aug 6, 2019 at 4:48 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> Richard Biener <richard.guenther@gmail.com> writes:
> > On Mon, Aug 5, 2019 at 10:58 AM Richard Sandiford
> > <richard.sandiford@arm.com> wrote:
> >>
> >> unmodified_param_1 used tree_to_shwi without first checking
> >> tree_fits_shwi_p.  This is needed by the SVE ACLE support and
> >> is hard to test independently.
> >>
> >> Tested on aarch64-linux-gnu, armeb-eabi and x86_64-linux-gnu.
> >> OK to install?
> >
> > Hmm, a better fix would be to use poly_X for *size_p.  There are also
> > quite a number of callers with NULL size_p which you unduly
> > pessimize for SVE.
>
> OK, you guilt-tripped me into doing it properly. :-)  How does this look?
>
> Tested as before.

OK.

Thanks,
Richard.

> Richard
>
>
> 2019-08-06  Richard Sandiford  <richard.sandiford@arm.com>
>
> gcc/
>         * data-streamer.h (streamer_write_poly_uint64): Declare.
>         (streamer_read_poly_uint64): Likewise.
>         * data-streamer-in.c (streamer_read_poly_uint64): New function.
>         * data-streamer-out.c (streamer_write_poly_uint64): Likewise.
>         * ipa-predicate.h (condition::size): Turn into a poly_int64.
>         (add_condition): Take a poly_int64 size.
>         * ipa-predicate.c (add_condition): Likewise.
>         * ipa-prop.h (ipa_load_from_parm_agg): Take a poly_int64 size pointer.
>         * ipa-prop.c (ipa_load_from_parm_agg): Likewise.
>         (ipcp_modif_dom_walker::before_dom_children): Update accordingly.
>         * ipa-fnsummary.c (evaluate_conditions_for_known_args): Handle
>         condition::size as a poly_int64.
>         (unmodified_parm_1): Take a poly_int64 size pointer.
>         (unmodified_parm): Likewise.
>         (unmodified_parm_or_parm_agg_item): Likewise.
>         (set_cond_stmt_execution_predicate): Update accordingly.
>         (set_switch_stmt_execution_predicate): Likewise.
>         (will_be_nonconstant_expr_predicate): Likewise.
>         (will_be_nonconstant_predicate): Likewise.
>         (inline_read_section): Stream condition::size as a poly_int.
>         (ipa_fn_summary_write): Likewise.
>
> Index: gcc/data-streamer.h
> ===================================================================
> --- gcc/data-streamer.h 2019-07-10 19:41:26.375898187 +0100
> +++ gcc/data-streamer.h 2019-08-06 15:45:32.908297910 +0100
> @@ -53,6 +53,7 @@ HOST_WIDE_INT bp_unpack_var_len_int (str
>  void streamer_write_zero (struct output_block *);
>  void streamer_write_uhwi (struct output_block *, unsigned HOST_WIDE_INT);
>  void streamer_write_hwi (struct output_block *, HOST_WIDE_INT);
> +void streamer_write_poly_uint64 (struct output_block *, poly_uint64);
>  void streamer_write_gcov_count (struct output_block *, gcov_type);
>  void streamer_write_string (struct output_block *, struct lto_output_stream *,
>                             const char *, bool);
> @@ -82,6 +83,7 @@ const char *bp_unpack_indexed_string (cl
>  const char *bp_unpack_string (class data_in *, struct bitpack_d *);
>  unsigned HOST_WIDE_INT streamer_read_uhwi (class lto_input_block *);
>  HOST_WIDE_INT streamer_read_hwi (class lto_input_block *);
> +poly_uint64 streamer_read_poly_uint64 (class lto_input_block *);
>  gcov_type streamer_read_gcov_count (class lto_input_block *);
>  wide_int streamer_read_wide_int (class lto_input_block *);
>  widest_int streamer_read_widest_int (class lto_input_block *);
> Index: gcc/data-streamer-in.c
> ===================================================================
> --- gcc/data-streamer-in.c      2019-07-10 19:41:20.147948065 +0100
> +++ gcc/data-streamer-in.c      2019-08-06 15:45:32.908297910 +0100
> @@ -175,6 +175,17 @@ streamer_read_hwi (class lto_input_block
>      }
>  }
>
> +/* Read a poly_uint64 from IB.  */
> +
> +poly_uint64
> +streamer_read_poly_uint64 (class lto_input_block *ib)
> +{
> +  poly_uint64 res;
> +  for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
> +    res.coeffs[i] = streamer_read_uhwi (ib);
> +  return res;
> +}
> +
>  /* Read gcov_type value from IB.  */
>
>  gcov_type
> Index: gcc/data-streamer-out.c
> ===================================================================
> --- gcc/data-streamer-out.c     2019-03-08 18:14:27.285004225 +0000
> +++ gcc/data-streamer-out.c     2019-08-06 15:45:32.908297910 +0100
> @@ -220,6 +220,15 @@ streamer_write_hwi (struct output_block
>    streamer_write_hwi_stream (ob->main_stream, work);
>  }
>
> +/* Write a poly_uint64 value WORK to OB->main_stream.  */
> +
> +void
> +streamer_write_poly_uint64 (struct output_block *ob, poly_uint64 work)
> +{
> +  for (int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
> +    streamer_write_uhwi_stream (ob->main_stream, work.coeffs[i]);
> +}
> +
>  /* Write a gcov counter value WORK to OB->main_stream.  */
>
>  void
> Index: gcc/ipa-predicate.h
> ===================================================================
> --- gcc/ipa-predicate.h 2019-07-10 19:41:27.163891877 +0100
> +++ gcc/ipa-predicate.h 2019-08-06 15:45:32.908297910 +0100
> @@ -31,7 +31,7 @@ struct GTY(()) condition
>       loaded.  */
>    HOST_WIDE_INT offset;
>    /* Size of the access reading the data (or the PARM_DECL SSA_NAME).  */
> -  HOST_WIDE_INT size;
> +  poly_int64 size;
>    tree val;
>    int operand_num;
>    ENUM_BITFIELD(tree_code) code : 16;
> @@ -228,5 +228,5 @@ typedef uint32_t clause_t;
>
>  void dump_condition (FILE *f, conditions conditions, int cond);
>  predicate add_condition (class ipa_fn_summary *summary, int operand_num,
> -                        HOST_WIDE_INT size, struct agg_position_info *aggpos,
> +                        poly_int64 size, struct agg_position_info *aggpos,
>                          enum tree_code code, tree val);
> Index: gcc/ipa-predicate.c
> ===================================================================
> --- gcc/ipa-predicate.c 2019-07-10 19:41:27.159891908 +0100
> +++ gcc/ipa-predicate.c 2019-08-06 15:45:32.908297910 +0100
> @@ -523,7 +523,7 @@ predicate::stream_out (struct output_blo
>
>  predicate
>  add_condition (class ipa_fn_summary *summary, int operand_num,
> -              HOST_WIDE_INT size, struct agg_position_info *aggpos,
> +              poly_int64 size, struct agg_position_info *aggpos,
>                enum tree_code code, tree val)
>  {
>    int i;
> @@ -549,7 +549,7 @@ add_condition (class ipa_fn_summary *sum
>    for (i = 0; vec_safe_iterate (summary->conds, i, &c); i++)
>      {
>        if (c->operand_num == operand_num
> -         && c->size == size
> +         && maybe_ne (c->size, size)
>           && c->code == code
>           && c->val == val
>           && c->agg_contents == agg_contents
> Index: gcc/ipa-prop.h
> ===================================================================
> --- gcc/ipa-prop.h      2019-07-10 19:41:27.151891973 +0100
> +++ gcc/ipa-prop.h      2019-08-06 15:45:32.912297882 +0100
> @@ -763,7 +763,7 @@ tree ipa_find_agg_cst_for_param (struct
>  bool ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
>                              vec<ipa_param_descriptor, va_gc> *descriptors,
>                              gimple *stmt, tree op, int *index_p,
> -                            HOST_WIDE_INT *offset_p, HOST_WIDE_INT *size_p,
> +                            HOST_WIDE_INT *offset_p, poly_int64 *size_p,
>                              bool *by_ref, bool *guaranteed_unmodified = NULL);
>
>  /* Debugging interface.  */
> Index: gcc/ipa-prop.c
> ===================================================================
> --- gcc/ipa-prop.c      2019-07-10 19:41:27.151891973 +0100
> +++ gcc/ipa-prop.c      2019-08-06 15:45:32.912297882 +0100
> @@ -1059,7 +1059,7 @@ parm_ref_data_pass_through_p (struct ipa
>  ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
>                         vec<ipa_param_descriptor, va_gc> *descriptors,
>                         gimple *stmt, tree op, int *index_p,
> -                       HOST_WIDE_INT *offset_p, HOST_WIDE_INT *size_p,
> +                       HOST_WIDE_INT *offset_p, poly_int64 *size_p,
>                         bool *by_ref_p, bool *guaranteed_unmodified)
>  {
>    int index;
> @@ -4917,7 +4917,8 @@ ipcp_modif_dom_walker::before_dom_childr
>        struct ipa_agg_replacement_value *v;
>        gimple *stmt = gsi_stmt (gsi);
>        tree rhs, val, t;
> -      HOST_WIDE_INT offset, size;
> +      HOST_WIDE_INT offset;
> +      poly_int64 size;
>        int index;
>        bool by_ref, vce;
>
> @@ -4952,7 +4953,8 @@ ipcp_modif_dom_walker::before_dom_childr
>           break;
>        if (!v
>           || v->by_ref != by_ref
> -         || tree_to_shwi (TYPE_SIZE (TREE_TYPE (v->value))) != size)
> +         || maybe_ne (tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (v->value))),
> +                      size))
>         continue;
>
>        gcc_checking_assert (is_gimple_ip_invariant (v->value));
> Index: gcc/ipa-fnsummary.c
> ===================================================================
> --- gcc/ipa-fnsummary.c 2019-08-05 17:46:25.000000000 +0100
> +++ gcc/ipa-fnsummary.c 2019-08-06 15:45:32.908297910 +0100
> @@ -382,7 +382,7 @@ evaluate_conditions_for_known_args (stru
>           continue;
>         }
>
> -      if (tree_to_shwi (TYPE_SIZE (TREE_TYPE (val))) != c->size)
> +      if (maybe_ne (tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (val))), c->size))
>         {
>           clause |= 1 << (i + predicate::first_dynamic_condition);
>           nonspec_clause |= 1 << (i + predicate::first_dynamic_condition);
> @@ -922,7 +922,7 @@ mark_modified (ao_ref *ao ATTRIBUTE_UNUS
>
>  static tree
>  unmodified_parm_1 (ipa_func_body_info *fbi, gimple *stmt, tree op,
> -                  HOST_WIDE_INT *size_p)
> +                  poly_int64 *size_p)
>  {
>    /* SSA_NAME referring to parm default def?  */
>    if (TREE_CODE (op) == SSA_NAME
> @@ -930,7 +930,7 @@ unmodified_parm_1 (ipa_func_body_info *f
>        && TREE_CODE (SSA_NAME_VAR (op)) == PARM_DECL)
>      {
>        if (size_p)
> -       *size_p = tree_to_shwi (TYPE_SIZE (TREE_TYPE (op)));
> +       *size_p = tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (op)));
>        return SSA_NAME_VAR (op);
>      }
>    /* Non-SSA parm reference?  */
> @@ -951,7 +951,7 @@ unmodified_parm_1 (ipa_func_body_info *f
>        if (!modified)
>         {
>           if (size_p)
> -           *size_p = tree_to_shwi (TYPE_SIZE (TREE_TYPE (op)));
> +           *size_p = tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (op)));
>           return op;
>         }
>      }
> @@ -965,7 +965,7 @@ unmodified_parm_1 (ipa_func_body_info *f
>
>  static tree
>  unmodified_parm (ipa_func_body_info *fbi, gimple *stmt, tree op,
> -                HOST_WIDE_INT *size_p)
> +                poly_int64 *size_p)
>  {
>    tree res = unmodified_parm_1 (fbi, stmt, op, size_p);
>    if (res)
> @@ -990,7 +990,7 @@ unmodified_parm (ipa_func_body_info *fbi
>  static bool
>  unmodified_parm_or_parm_agg_item (struct ipa_func_body_info *fbi,
>                                   gimple *stmt, tree op, int *index_p,
> -                                 HOST_WIDE_INT *size_p,
> +                                 poly_int64 *size_p,
>                                   struct agg_position_info *aggpos)
>  {
>    tree res = unmodified_parm_1 (fbi, stmt, op, size_p);
> @@ -1169,7 +1169,7 @@ set_cond_stmt_execution_predicate (struc
>    gimple *last;
>    tree op;
>    int index;
> -  HOST_WIDE_INT size;
> +  poly_int64 size;
>    struct agg_position_info aggpos;
>    enum tree_code code, inverted_code;
>    edge e;
> @@ -1254,7 +1254,7 @@ set_switch_stmt_execution_predicate (str
>    gimple *lastg;
>    tree op;
>    int index;
> -  HOST_WIDE_INT size;
> +  poly_int64 size;
>    struct agg_position_info aggpos;
>    edge e;
>    edge_iterator ei;
> @@ -1393,7 +1393,7 @@ will_be_nonconstant_expr_predicate (ipa_
>  {
>    tree parm;
>    int index;
> -  HOST_WIDE_INT size;
> +  poly_int64 size;
>
>    while (UNARY_CLASS_P (expr))
>      expr = TREE_OPERAND (expr, 0);
> @@ -1468,7 +1468,7 @@ will_be_nonconstant_predicate (struct ip
>    predicate op_non_const;
>    bool is_load;
>    int base_index;
> -  HOST_WIDE_INT size;
> +  poly_int64 size;
>    struct agg_position_info aggpos;
>
>    /* What statments might be optimized away
> @@ -1524,7 +1524,7 @@ will_be_nonconstant_predicate (struct ip
>      op_non_const = false;
>    FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE)
>      {
> -      HOST_WIDE_INT size;
> +      poly_int64 size;
>        tree parm = unmodified_parm (fbi, stmt, use, &size);
>        int index;
>
> @@ -3292,7 +3292,7 @@ inline_read_section (struct lto_file_dec
>         {
>           struct condition c;
>           c.operand_num = streamer_read_uhwi (&ib);
> -         c.size = streamer_read_uhwi (&ib);
> +         c.size = streamer_read_poly_uint64 (&ib);
>           c.code = (enum tree_code) streamer_read_uhwi (&ib);
>           c.val = stream_read_tree (&ib, data_in);
>           bp = streamer_read_bitpack (&ib);
> @@ -3446,7 +3446,7 @@ ipa_fn_summary_write (void)
>           for (i = 0; vec_safe_iterate (info->conds, i, &c); i++)
>             {
>               streamer_write_uhwi (ob, c->operand_num);
> -             streamer_write_uhwi (ob, c->size);
> +             streamer_write_poly_uint64 (ob, c->size);
>               streamer_write_uhwi (ob, c->code);
>               stream_write_tree (ob, c->val, true);
>               bp = bitpack_create (ob->main_stream);
diff mbox series

Patch

Index: gcc/ipa-fnsummary.c
===================================================================
--- gcc/ipa-fnsummary.c	2019-07-16 09:11:50.509067138 +0100
+++ gcc/ipa-fnsummary.c	2019-08-05 09:57:28.553617299 +0100
@@ -927,7 +927,8 @@  unmodified_parm_1 (ipa_func_body_info *f
   /* SSA_NAME referring to parm default def?  */
   if (TREE_CODE (op) == SSA_NAME
       && SSA_NAME_IS_DEFAULT_DEF (op)
-      && TREE_CODE (SSA_NAME_VAR (op)) == PARM_DECL)
+      && TREE_CODE (SSA_NAME_VAR (op)) == PARM_DECL
+      && tree_fits_shwi_p (TYPE_SIZE (TREE_TYPE (op))))
     {
       if (size_p)
 	*size_p = tree_to_shwi (TYPE_SIZE (TREE_TYPE (op)));