Hi,
this patch makes inline_read_sections to allocate vector in proper size
saving bit of register scaling overhead.

Bootstrapped/regtested x86_64-linux, comitted.

        * ipa-fnsummary.c (inline_read_section): Set vector size
        ahead of time.

Index: ipa-fnsummary.c
===================================================================
--- ipa-fnsummary.c     (revision 277754)
+++ ipa-fnsummary.c     (working copy)
@@ -3614,6 +3614,8 @@ inline_read_section (struct lto_file_dec
 
       count2 = streamer_read_uhwi (&ib);
       gcc_assert (!info || !info->conds);
+      if (info)
+        vec_safe_reserve_exact (info->conds, count2);
       for (j = 0; j < count2; j++)
        {
          struct condition c;
@@ -3627,8 +3629,10 @@ inline_read_section (struct lto_file_dec
          c.by_ref = bp_unpack_value (&bp, 1);
          if (c.agg_contents)
            c.offset = streamer_read_uhwi (&ib);
-         c.param_ops = NULL;
          count3 = streamer_read_uhwi (&ib);
+         c.param_ops = NULL;
+         if (info)
+           vec_safe_reserve_exact (c.param_ops, count3);
          for (k = 0; k < count3; k++)
            {
              struct expr_eval_op op;
@@ -3658,13 +3662,16 @@ inline_read_section (struct lto_file_dec
                  fatal_error (UNKNOWN_LOCATION,
                               "invalid fnsummary in LTO stream");
                }
-             vec_safe_push (c.param_ops, op);
+             if (info)
+               c.param_ops->quick_push (op);
            }
          if (info)
-           vec_safe_push (info->conds, c);
+           info->conds->quick_push (c);
        }
       count2 = streamer_read_uhwi (&ib);
       gcc_assert (!info || !info->size_time_table);
+      if (info && count2)
+        vec_safe_reserve_exact (info->size_time_table, count2);
       for (j = 0; j < count2; j++)
        {
          class size_time_entry e;
@@ -3675,7 +3682,7 @@ inline_read_section (struct lto_file_dec
          e.nonconst_predicate.stream_in (&ib);
 
          if (info)
-           vec_safe_push (info->size_time_table, e);
+           info->size_time_table->quick_push (e);
        }
 
       p.stream_in (&ib);

Reply via email to