From: Kito Cheng <kito.cheng@gmail.com>
To: juzhe.zhong@rivai.ai
Cc: gcc-patches@gcc.gnu.org, palmer@dabbelt.com
Subject: Re: [PATCH] RISC-V: Cleanup the codes of bitmap create and free [NFC]
Date: Fri, 27 Jan 2023 03:14:09 +0800 [thread overview]
Message-ID: <CA+yXCZDg7TdgwnrpR6YSm8q5OxvKnddyfTkzqx50P7imfirF5A@mail.gmail.com> (raw)
In-Reply-To: <20230109223307.144358-1-juzhe.zhong@rivai.ai>
[-- Attachment #1: Type: text/plain, Size: 5959 bytes --]
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
>
>
prev parent reply other threads:[~2023-01-26 19:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 22:33 juzhe.zhong
2023-01-26 19:14 ` Kito Cheng [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+yXCZDg7TdgwnrpR6YSm8q5OxvKnddyfTkzqx50P7imfirF5A@mail.gmail.com \
--to=kito.cheng@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=juzhe.zhong@rivai.ai \
--cc=palmer@dabbelt.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).