Message ID | 20230109223307.144358-1-juzhe.zhong@rivai.ai |
---|---|
State | New |
Headers | show |
Series | RISC-V: Cleanup the codes of bitmap create and free [NFC] | expand |
committed, thanks. On Tue, Jan 10, 2023 at 6:33 AM <juzhe.zhong@rivai.ai> wrote: > From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai> > > 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. > > --- > 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 d42cfa91d63..7800c2ee509 100644 > --- a/gcc/config/riscv/riscv-vsetvl.cc > +++ b/gcc/config/riscv/riscv-vsetvl.cc > @@ -1569,18 +1569,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 > @@ -2480,32 +2524,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 33481a87163..dc16c55b918 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; > }; > -- > 2.36.1 > >
diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index d42cfa91d63..7800c2ee509 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -1569,18 +1569,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 @@ -2480,32 +2524,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 33481a87163..dc16c55b918 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; };
From: Ju-Zhe Zhong <juzhe.zhong@rivai.ai> 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. --- gcc/config/riscv/riscv-vsetvl.cc | 95 +++++++++++++++++++------------- gcc/config/riscv/riscv-vsetvl.h | 2 + 2 files changed, 59 insertions(+), 38 deletions(-)