From: Richard Biener <richard.guenther@gmail.com>
To: Aldy Hernandez <aldyh@redhat.com>
Cc: Andrew MacLeod <amacleod@redhat.com>,
GCC patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Remove path_range_query constructor that takes an edge.
Date: Fri, 19 Aug 2022 09:31:29 +0200 [thread overview]
Message-ID: <CAFiYyc3oe7k4ZO_r3fsg7YptNVB=vCtU6=uxEPd7O_n3BGSJiw@mail.gmail.com> (raw)
In-Reply-To: <20220818161323.642918-1-aldyh@redhat.com>
On Thu, Aug 18, 2022 at 6:13 PM Aldy Hernandez <aldyh@redhat.com> wrote:
>
> The path_range_query constructor that takes an edge is really a
> convenience function for the loop-ch pass. It feels wrong to pollute
> the API with such a specialized function that could be done with
> a small inline function closer to its user.
>
> As an added benefit, we remove one use of reset_path. The last
> remaining one is the forward threader one.
>
> OK?
OK.
> gcc/ChangeLog:
>
> * gimple-range-path.cc (path_range_query::path_range_query):
> Remove constructor that takes edge.
> * gimple-range-path.h (class path_range_query): Same.
> * tree-ssa-loop-ch.cc (edge_range_query): New.
> (entry_loop_condition_is_static): Call edge_range_query.
> ---
> gcc/gimple-range-path.cc | 15 ---------------
> gcc/gimple-range-path.h | 1 -
> gcc/tree-ssa-loop-ch.cc | 17 +++++++++++++++--
> 3 files changed, 15 insertions(+), 18 deletions(-)
>
> diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
> index ba7c2ed9b47..bc2879c0c57 100644
> --- a/gcc/gimple-range-path.cc
> +++ b/gcc/gimple-range-path.cc
> @@ -59,21 +59,6 @@ path_range_query::path_range_query (gimple_ranger &ranger, bool resolve)
> m_oracle = new path_oracle (m_ranger.oracle ());
> }
>
> -path_range_query::path_range_query (gimple_ranger &ranger,
> - edge e,
> - bool resolve)
> - : m_cache (new ssa_global_cache),
> - m_has_cache_entry (BITMAP_ALLOC (NULL)),
> - m_ranger (ranger),
> - m_resolve (resolve)
> -{
> - m_oracle = new path_oracle (m_ranger.oracle ());
> - auto_vec<basic_block> bbs (2);
> - bbs.quick_push (e->dest);
> - bbs.quick_push (e->src);
> - reset_path (bbs, NULL);
> -}
> -
> path_range_query::~path_range_query ()
> {
> delete m_oracle;
> diff --git a/gcc/gimple-range-path.h b/gcc/gimple-range-path.h
> index 483fde0d431..9f2d6d92dab 100644
> --- a/gcc/gimple-range-path.h
> +++ b/gcc/gimple-range-path.h
> @@ -37,7 +37,6 @@ public:
> const bitmap_head *dependencies = NULL,
> bool resolve = true);
> path_range_query (gimple_ranger &ranger, bool resolve = true);
> - path_range_query (gimple_ranger &ranger, edge e, bool resolve = true);
> virtual ~path_range_query ();
> void reset_path (const vec<basic_block> &, const bitmap_head *dependencies);
> bool range_of_expr (vrange &r, tree name, gimple * = NULL) override;
> diff --git a/gcc/tree-ssa-loop-ch.cc b/gcc/tree-ssa-loop-ch.cc
> index 96816b89287..9c316887d5b 100644
> --- a/gcc/tree-ssa-loop-ch.cc
> +++ b/gcc/tree-ssa-loop-ch.cc
> @@ -45,6 +45,20 @@ along with GCC; see the file COPYING3. If not see
> increases effectiveness of code motion optimizations, and reduces the need
> for loop preconditioning. */
>
> +/* Given a path through edge E, whose last statement is COND, return
> + the range of the solved conditional in R. */
> +
> +static void
> +edge_range_query (irange &r, edge e, gcond *cond, gimple_ranger &ranger)
> +{
> + auto_vec<basic_block> path (2);
> + path.safe_push (e->dest);
> + path.safe_push (e->src);
> + path_range_query query (ranger, path);
> + if (!query.range_of_stmt (r, cond))
> + r.set_varying (boolean_type_node);
> +}
> +
> /* Return true if the condition on the first iteration of the loop can
> be statically determined. */
>
> @@ -72,8 +86,7 @@ entry_loop_condition_is_static (class loop *l, gimple_ranger *ranger)
> desired_static_value = boolean_true_node;
>
> int_range<2> r;
> - path_range_query query (*ranger, e);
> - query.range_of_stmt (r, last);
> + edge_range_query (r, e, last, *ranger);
> return r == int_range<2> (desired_static_value, desired_static_value);
> }
>
> --
> 2.37.1
>
prev parent reply other threads:[~2022-08-19 7:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-18 16:13 Aldy Hernandez
2022-08-19 7:31 ` Richard Biener [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='CAFiYyc3oe7k4ZO_r3fsg7YptNVB=vCtU6=uxEPd7O_n3BGSJiw@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@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: 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).