public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-5410] RISC-V: Cleanup the codes of bitmap create and free [NFC]
@ 2023-01-26 19:12 Kito Cheng
  0 siblings, 0 replies; only message in thread
From: Kito Cheng @ 2023-01-26 19:12 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:cfe3fbc678d7b69785d2b017d3ff3cd78cd91580

commit r13-5410-gcfe3fbc678d7b69785d2b017d3ff3cd78cd91580
Author: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
Date:   Tue Jan 10 06:33:07 2023 +0800

    RISC-V: Cleanup the codes of bitmap create and free [NFC]
    
    This patch is a NFC patch to move the codes into a wrapper function so that
    they can be reused. I will reuse them in the following patches.
    
    gcc/ChangeLog:
    
            * config/riscv/riscv-vsetvl.cc (vector_infos_manager::create_bitmap_vectors): New function.
            (vector_infos_manager::free_bitmap_vectors): Ditto.
            (pass_vsetvl::pre_vsetvl): Adjust codes.
            * config/riscv/riscv-vsetvl.h: New function declaration.

Diff:
---
 gcc/config/riscv/riscv-vsetvl.cc | 95 ++++++++++++++++++++++++----------------
 gcc/config/riscv/riscv-vsetvl.h  |  2 +
 2 files changed, 59 insertions(+), 38 deletions(-)

diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index 9ed081d0a72..f67459ca8ca 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -1570,18 +1570,62 @@ vector_infos_manager::release (void)
     vector_exprs.release ();
 
   if (optimize > 0)
-    {
-      /* Finished. Free up all the things we've allocated.  */
-      free_edge_list (vector_edge_list);
-      sbitmap_vector_free (vector_del);
-      sbitmap_vector_free (vector_insert);
-      sbitmap_vector_free (vector_kill);
-      sbitmap_vector_free (vector_antic);
-      sbitmap_vector_free (vector_transp);
-      sbitmap_vector_free (vector_comp);
-      sbitmap_vector_free (vector_avin);
-      sbitmap_vector_free (vector_avout);
-    }
+    free_bitmap_vectors ();
+}
+
+void
+vector_infos_manager::create_bitmap_vectors (void)
+{
+  /* Create the bitmap vectors.  */
+  vector_antic = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
+				       vector_exprs.length ());
+  vector_transp = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
+					vector_exprs.length ());
+  vector_comp = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
+				      vector_exprs.length ());
+  vector_avin = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
+				      vector_exprs.length ());
+  vector_avout = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
+				       vector_exprs.length ());
+  vector_kill = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
+				      vector_exprs.length ());
+
+  bitmap_vector_ones (vector_transp, last_basic_block_for_fn (cfun));
+  bitmap_vector_clear (vector_antic, last_basic_block_for_fn (cfun));
+  bitmap_vector_clear (vector_comp, last_basic_block_for_fn (cfun));
+}
+
+void
+vector_infos_manager::free_bitmap_vectors (void)
+{
+  /* Finished. Free up all the things we've allocated.  */
+  free_edge_list (vector_edge_list);
+  if (vector_del)
+    sbitmap_vector_free (vector_del);
+  if (vector_insert)
+    sbitmap_vector_free (vector_insert);
+  if (vector_kill)
+    sbitmap_vector_free (vector_kill);
+  if (vector_antic)
+    sbitmap_vector_free (vector_antic);
+  if (vector_transp)
+    sbitmap_vector_free (vector_transp);
+  if (vector_comp)
+    sbitmap_vector_free (vector_comp);
+  if (vector_avin)
+    sbitmap_vector_free (vector_avin);
+  if (vector_avout)
+    sbitmap_vector_free (vector_avout);
+
+  vector_edge_list = nullptr;
+  vector_kill = nullptr;
+  vector_del = nullptr;
+  vector_insert = nullptr;
+  vector_antic = nullptr;
+  vector_transp = nullptr;
+  vector_comp = nullptr;
+  vector_avin = nullptr;
+  vector_avout = nullptr;
 }
 
 void
@@ -2479,32 +2523,7 @@ pass_vsetvl::pre_vsetvl (void)
   /* Compute entity list.  */
   prune_expressions ();
 
-  /* Create the bitmap vectors.  */
-  m_vector_manager->vector_antic
-    = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
-			    m_vector_manager->vector_exprs.length ());
-  m_vector_manager->vector_transp
-    = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
-			    m_vector_manager->vector_exprs.length ());
-  m_vector_manager->vector_comp
-    = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
-			    m_vector_manager->vector_exprs.length ());
-  m_vector_manager->vector_avin
-    = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
-			    m_vector_manager->vector_exprs.length ());
-  m_vector_manager->vector_avout
-    = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
-			    m_vector_manager->vector_exprs.length ());
-  m_vector_manager->vector_kill
-    = sbitmap_vector_alloc (last_basic_block_for_fn (cfun),
-			    m_vector_manager->vector_exprs.length ());
-
-  bitmap_vector_ones (m_vector_manager->vector_transp,
-		      last_basic_block_for_fn (cfun));
-  bitmap_vector_clear (m_vector_manager->vector_antic,
-		       last_basic_block_for_fn (cfun));
-  bitmap_vector_clear (m_vector_manager->vector_comp,
-		       last_basic_block_for_fn (cfun));
+  m_vector_manager->create_bitmap_vectors ();
   compute_local_properties ();
   m_vector_manager->vector_edge_list = pre_edge_lcm_avs (
     m_vector_manager->vector_exprs.length (), m_vector_manager->vector_transp,
diff --git a/gcc/config/riscv/riscv-vsetvl.h b/gcc/config/riscv/riscv-vsetvl.h
index 72a02289adb..1038f35523e 100644
--- a/gcc/config/riscv/riscv-vsetvl.h
+++ b/gcc/config/riscv/riscv-vsetvl.h
@@ -341,6 +341,8 @@ public:
   bool all_same_ratio_p (sbitmap) const;
 
   void release (void);
+  void create_bitmap_vectors (void);
+  void free_bitmap_vectors (void);
 
   void dump (FILE *) const;
 };

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

only message in thread, other threads:[~2023-01-26 19:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-26 19:12 [gcc r13-5410] RISC-V: Cleanup the codes of bitmap create and free [NFC] Kito Cheng

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).