public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/loop-unswitching-switch-v5)] Ranger - grow. Date: Tue, 9 Nov 2021 10:06:01 +0000 (GMT) [thread overview] Message-ID: <20211109100601.6C5D03858401@sourceware.org> (raw) https://gcc.gnu.org/g:5acf02cf9ab6b1af474fb0f2b8f86c6d43c835e1 commit 5acf02cf9ab6b1af474fb0f2b8f86c6d43c835e1 Author: Martin Liska <mliska@suse.cz> Date: Tue Nov 9 10:08:31 2021 +0100 Ranger - grow. Diff: --- gcc/gimple-range-cache.cc | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index e5591bab0ef..e010d35904f 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -210,6 +210,7 @@ protected: int_range<2> m_undefined; tree m_type; irange_allocator *m_irange_allocator; + void grow (); }; @@ -229,12 +230,33 @@ sbr_vector::sbr_vector (tree t, irange_allocator *allocator) m_undefined.set_undefined (); } +void +sbr_vector::grow () +{ + int curr_bb_size = last_basic_block_for_fn (cfun); + gcc_checking_assert (curr_bb_size > m_tab_size); + + int inc = MAX ((curr_bb_size - m_tab_size) * 2, 128); + inc = MAX (inc, curr_bb_size / 10); + int new_size = inc + curr_bb_size; + + irange **t = (irange **)m_irange_allocator->get_memory (new_size + * sizeof (irange *)); + memcpy (t, m_tab, m_tab_size * sizeof (irange *)); + memset (t + m_tab_size, 0, (new_size - m_tab_size) * sizeof (irange *)); + + m_tab = t; + m_tab_size = new_size; +} + // Set the range for block BB to be R. bool sbr_vector::set_bb_range (const_basic_block bb, const irange &r) { irange *m; + if (bb->index >= m_tab_size) + grow (); gcc_checking_assert (bb->index < m_tab_size); if (r.varying_p ()) m = &m_varying; @@ -252,6 +274,8 @@ sbr_vector::set_bb_range (const_basic_block bb, const irange &r) bool sbr_vector::get_bb_range (irange &r, const_basic_block bb) { + if (bb->index >= m_tab_size) + grow (); gcc_checking_assert (bb->index < m_tab_size); irange *m = m_tab[bb->index]; if (m) @@ -267,8 +291,9 @@ sbr_vector::get_bb_range (irange &r, const_basic_block bb) bool sbr_vector::bb_range_p (const_basic_block bb) { - gcc_checking_assert (bb->index < m_tab_size); - return m_tab[bb->index] != NULL; + if (bb->index < m_tab_size) + return m_tab[bb->index] != NULL; + return false; } // This class implements the on entry cache via a sparse bitmap.
reply other threads:[~2021-11-09 10:06 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211109100601.6C5D03858401@sourceware.org \ --to=marxin@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).