Richi has asked the we break the wide-int patch so that the individual port and 
front end maintainers can review their parts without have to go through the 
entire patch.    This patch covers the lto code.

Ok?

        * lto-streamer-in.c
        (input_cfg): Use wide-int interfaces.
        (lto_input_tree_1): Likewise.
        * lto-streamer-out.c
        (hash_tree): Use wide-int interfaces.
        (output_cfg): Likewise.

lto:
        * lto.c
        (compare_tree_sccs_1): Use wide-int interfaces.
        * lto-lang.c
        (get_nonnull_operand): Use wide-int interfaces.


diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index de25925..f2a3c0f 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -702,14 +702,26 @@ input_cfg (struct lto_input_block *ib, struct function 
*fn,
       loop->any_upper_bound = streamer_read_hwi (ib);
       if (loop->any_upper_bound)
        {
-         loop->nb_iterations_upper_bound.low = streamer_read_uhwi (ib);
-         loop->nb_iterations_upper_bound.high = streamer_read_hwi (ib);
+         HOST_WIDE_INT a[WIDE_INT_MAX_ELTS];
+         int i;
+         int prec ATTRIBUTE_UNUSED = streamer_read_uhwi (ib);
+         int len = streamer_read_uhwi (ib);
+         for (i = 0; i < len; i++)
+           a[i] = streamer_read_hwi (ib);
+
+         loop->nb_iterations_upper_bound = widest_int::from_array (a, len);
        }
       loop->any_estimate = streamer_read_hwi (ib);
       if (loop->any_estimate)
        {
-         loop->nb_iterations_estimate.low = streamer_read_uhwi (ib);
-         loop->nb_iterations_estimate.high = streamer_read_hwi (ib);
+         HOST_WIDE_INT a[WIDE_INT_MAX_ELTS];
+         int i;
+         int prec ATTRIBUTE_UNUSED = streamer_read_uhwi (ib);
+         int len = streamer_read_uhwi (ib);
+         for (i = 0; i < len; i++)
+           a[i] = streamer_read_hwi (ib);
+
+         loop->nb_iterations_estimate = widest_int::from_array (a, len);
        }
 
       place_new_loop (fn, loop);
@@ -1259,12 +1271,17 @@ lto_input_tree_1 (struct lto_input_block *ib, struct 
data_in *data_in,
     }
   else if (tag == LTO_integer_cst)
     {
-      /* For shared integer constants in singletons we can use the existing
-         tree integer constant merging code.  */
+      /* For shared integer constants in singletons we can use the
+         existing tree integer constant merging code.  */
       tree type = stream_read_tree (ib, data_in);
-      unsigned HOST_WIDE_INT low = streamer_read_uhwi (ib);
-      HOST_WIDE_INT high = streamer_read_hwi (ib);
-      result = build_int_cst_wide (type, low, high);
+      unsigned HOST_WIDE_INT len = streamer_read_uhwi (ib);
+      unsigned HOST_WIDE_INT i;
+      HOST_WIDE_INT a[WIDE_INT_MAX_ELTS];
+
+      for (i = 0; i < len; i++)
+       a[i] = streamer_read_hwi (ib);
+      result = wide_int_to_tree (type, wide_int::from_array
+                                (a, len, TYPE_PRECISION (type)));
       streamer_tree_cache_append (data_in->reader_cache, result, hash);
     }
   else if (tag == LTO_tree_scc)
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 6f1585a..a06f386 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -714,8 +714,11 @@ hash_tree (struct streamer_tree_cache_d *cache, tree t)
 
   if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
     {
-      v = iterative_hash_host_wide_int (TREE_INT_CST_LOW (t), v);
-      v = iterative_hash_host_wide_int (TREE_INT_CST_HIGH (t), v);
+      int i;
+      v = iterative_hash_host_wide_int (TREE_INT_CST_NUNITS (t), v);
+      v = iterative_hash_host_wide_int (TREE_INT_CST_EXT_NUNITS (t), v);
+      for (i = 0; i < TREE_INT_CST_NUNITS (t); i++)
+       v = iterative_hash_host_wide_int (TREE_INT_CST_ELT (t, i), v);
     }
 
   if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST))
@@ -1631,14 +1634,24 @@ output_cfg (struct output_block *ob, struct function 
*fn)
       streamer_write_hwi (ob, loop->any_upper_bound);
       if (loop->any_upper_bound)
        {
-         streamer_write_uhwi (ob, loop->nb_iterations_upper_bound.low);
-         streamer_write_hwi (ob, loop->nb_iterations_upper_bound.high);
+         int len = loop->nb_iterations_upper_bound.get_len ();
+         int i;
+
+         streamer_write_uhwi (ob, 
loop->nb_iterations_upper_bound.get_precision ());
+         streamer_write_uhwi (ob, len);
+         for (i = 0; i < len; i++)
+           streamer_write_hwi (ob, loop->nb_iterations_upper_bound.elt (i));
        }
       streamer_write_hwi (ob, loop->any_estimate);
       if (loop->any_estimate)
        {
-         streamer_write_uhwi (ob, loop->nb_iterations_estimate.low);
-         streamer_write_hwi (ob, loop->nb_iterations_estimate.high);
+         int len = loop->nb_iterations_estimate.get_len ();
+         int i;
+
+         streamer_write_uhwi (ob, loop->nb_iterations_estimate.get_precision 
());
+         streamer_write_uhwi (ob, len);
+         for (i = 0; i < len; i++)
+           streamer_write_hwi (ob, loop->nb_iterations_estimate.elt (i));
        }
     }
 
diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c
index cb15ce3..a5f5d44 100644
--- a/gcc/lto/lto-lang.c
+++ b/gcc/lto/lto-lang.c
@@ -318,8 +318,7 @@ static bool
 get_nonnull_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp)
 {
   /* Verify the arg number is a constant.  */
-  if (TREE_CODE (arg_num_expr) != INTEGER_CST
-      || TREE_INT_CST_HIGH (arg_num_expr) != 0)
+  if (!tree_fits_uhwi_p (arg_num_expr))
     return false;
 
   *valp = TREE_INT_CST_LOW (arg_num_expr);
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 0211437..c43fe84 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -1215,8 +1215,8 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map)
 
   if (CODE_CONTAINS_STRUCT (code, TS_INT_CST))
     {
-      compare_values (TREE_INT_CST_LOW);
-      compare_values (TREE_INT_CST_HIGH);
+      if (!wi::eq_p (t1, t2))
+       return false;
     }
 
   if (CODE_CONTAINS_STRUCT (code, TS_REAL_CST))

Reply via email to