]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid re-allocating vector
authorRichard Biener <rguenther@suse.de>
Wed, 17 Apr 2024 11:20:40 +0000 (13:20 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 7 May 2024 13:28:55 +0000 (15:28 +0200)
The following avoids re-allocating the var map BB vector by
pre-allocating it to the exact size needed when operating on the
whole function.

* tree-ssa-live.cc (init_var_map): Pre-allocate vec_bbs vector
to the correct size and use quick_push.

gcc/tree-ssa-live.cc

index fa6be2fced308ea0b4312ab415e32bd2b7a7bf03..e6ae551a45789c2dc3745aaf8125802b966fee94 100644 (file)
@@ -113,8 +113,10 @@ init_var_map (int size, class loop *loop, bitmap bitint)
       map->outofssa_p = bitint == NULL;
       map->bitint = bitint;
       basic_block bb;
+      map->vec_bbs.reserve_exact (n_basic_blocks_for_fn (cfun)
+                                 - NUM_FIXED_BLOCKS);
       FOR_EACH_BB_FN (bb, cfun)
-       map->vec_bbs.safe_push (bb);
+       map->vec_bbs.quick_push (bb);
     }
   return map;
 }