From: Jan Hubicka <hubicka@ucw.cz>
To: Andrew MacLeod <amacleod@redhat.com>
Cc: aldyh@redhat.com, mjambor@suse.cz, gcc-patches@gcc.gnu.org,
jwakely@redhat.com
Subject: Re: Enable ranger for ipa-prop
Date: Wed, 28 Jun 2023 09:37:12 +0200 [thread overview]
Message-ID: <ZJvjKC20nyFd7EqB@kam.mff.cuni.cz> (raw)
In-Reply-To: <a4f6bf28-fe8a-d4db-9a10-0642559de1c6@redhat.com>
>
> On 6/27/23 12:24, Jan Hubicka wrote:
> > > On 6/27/23 09:19, Jan Hubicka wrote:
> > > > Hi,
> > > > as shown in the testcase (which would eventually be useful for
> > > > optimizing std::vector's push_back), ipa-prop can use context dependent ranger
> > > > queries for better value range info.
> > > >
> > > > Bootstrapped/regtested x86_64-linux, OK?
> > > Quick question.
> > >
> > > When you call enable_ranger(), its gives you a ranger back, but it also sets
> > > the range query for the specified context to that same instance. So from
> > > that point forward all existing calls to get_range_query(fun) will now use
> > > the context ranger
> > >
> > > enable_ranger (struct function *fun, bool use_imm_uses)
> > > <...>
> > > gcc_checking_assert (!fun->x_range_query);
> > > r = new gimple_ranger (use_imm_uses);
> > > fun->x_range_query = r;
> > > return r;
> > >
> > > So you probably dont have to pass a ranger around? or is that ranger you
> > > are passing for a different context?
> > I don't need passing ranger around - I just did not know that. I tought
> > the default one is the context insensitive one, I will simplify the
> > patch. I need to look more into how ranger works.
> >
> >
> No need. Its magic!
Cool, thanks for the explanation!
I pushed the following simplified version of the patch. Now back to
getting push_back faster :)
gcc/ChangeLog:
PR tree-optimization/110377
* ipa-prop.cc (ipa_compute_jump_functions_for_edge): Pass statement to
the ranger query.
(ipa_analyze_node): Enable ranger.
gcc/testsuite/ChangeLog:
PR tree-optimization/110377
* gcc.dg/ipa/pr110377.c: New test.
diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index 41c812194ca..33bda8288fc 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -2386,7 +2386,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
if (TREE_CODE (arg) == SSA_NAME
&& param_type
- && get_range_query (cfun)->range_of_expr (vr, arg)
+ && get_range_query (cfun)->range_of_expr (vr, arg, cs->call_stmt)
&& vr.nonzero_p ())
addr_nonzero = true;
else if (tree_single_nonzero_warnv_p (arg, &strict_overflow))
@@ -2408,7 +2408,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
&& Value_Range::supports_type_p (param_type)
&& irange::supports_p (TREE_TYPE (arg))
&& irange::supports_p (param_type)
- && get_range_query (cfun)->range_of_expr (vr, arg)
+ && get_range_query (cfun)->range_of_expr (vr, arg, cs->call_stmt)
&& !vr.undefined_p ())
{
Value_Range resvr (vr);
@@ -3190,7 +3190,9 @@ ipa_analyze_node (struct cgraph_node *node)
bi->cg_edges.safe_push (cs);
}
+ enable_ranger (cfun, false);
analysis_dom_walker (&fbi).walk (ENTRY_BLOCK_PTR_FOR_FN (cfun));
+ disable_ranger (cfun);
ipa_release_body_info (&fbi);
free_dominance_info (CDI_DOMINATORS);
diff --git a/gcc/testsuite/gcc.dg/ipa/pr110377.c b/gcc/testsuite/gcc.dg/ipa/pr110377.c
new file mode 100644
index 00000000000..63120a97bd0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr110377.c
@@ -0,0 +1,16 @@
+/* { dg-do compile */
+/* { dg-options "-O2 -fdump-ipa-cp" } */
+int test3(int);
+__attribute__ ((noinline))
+void test2(int a)
+{
+ test3(a);
+}
+void
+test(int n)
+{
+ if (n > 5)
+ __builtin_unreachable ();
+ test2(n);
+}
+/* { dg-final { scan-ipa-dump "-INF, 5" "cp" } } */
next prev parent reply other threads:[~2023-06-28 7:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-27 13:19 Jan Hubicka
2023-06-27 14:00 ` Andrew MacLeod
2023-06-27 16:24 ` Jan Hubicka
2023-06-27 17:54 ` Andrew MacLeod
2023-06-28 7:37 ` Jan Hubicka [this message]
2023-06-27 15:14 ` Martin Jambor
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=ZJvjKC20nyFd7EqB@kam.mff.cuni.cz \
--to=hubicka@ucw.cz \
--cc=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely@redhat.com \
--cc=mjambor@suse.cz \
/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).