From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 302B83858D1E for ; Wed, 28 Jun 2023 07:37:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 302B83858D1E Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id D6C0E281AB9; Wed, 28 Jun 2023 09:37:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1687937832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uZ374HVFeQ8OdTExS/b9LeCfKpuIZ+EQNQ7tiz09BJI=; b=AIdnz7w8iKiv1FE4cN62GUY19PRdRDJ9FF9+uG60YvJ1M4OHiKNdfDnuxfBE+zEGo74ei1 6tfu0HmVL7cCkqY1Uo+GHVvdCwMzBFFzUYW543UjXABftUTtkg2hnP8zn44iDxbZIWgtij bYUmTQhEBiKq3+DdQ0eFgcyd9N9Jvxk= Date: Wed, 28 Jun 2023 09:37:12 +0200 From: Jan Hubicka To: Andrew MacLeod Cc: aldyh@redhat.com, mjambor@suse.cz, gcc-patches@gcc.gnu.org, jwakely@redhat.com Subject: Re: Enable ranger for ipa-prop Message-ID: References: <4d2f5bc2-c4ff-7576-cb82-b6c8a1a1da5f@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > > 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" } } */