public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Avoid re-allocating vector
@ 2024-05-07 12:16 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-05-07 12:16 UTC (permalink / raw)
  To: gcc-patches

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.

Re-bootstrap and regtest running on x86_64-unknown-linux-gnu.

	* 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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-ssa-live.cc b/gcc/tree-ssa-live.cc
index fa6be2fced3..e6ae551a457 100644
--- a/gcc/tree-ssa-live.cc
+++ b/gcc/tree-ssa-live.cc
@@ -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;
 }
-- 
2.35.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-07 12:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-07 12:16 [PATCH] Avoid re-allocating vector Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).