From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id AB96F3858D28 for ; Tue, 27 Jun 2023 15:14:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AB96F3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A05FD21860; Tue, 27 Jun 2023 15:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1687878855; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mvvSdpXIedbTXAbSb7UutGw61tF99/DRU3/HmEFE0S8=; b=olhkDtVPu9K6hWqETYCZLEw1G8zMZ5qZPS2Eq+uiJr5RdclON9+rldC5o2eYixNLDds+q0 g47MeCPUBS3n04DCDw/bra7qnQ6qSX0tp1l9OE6p3b1+mpcHiLKAcCZ9Of4ZKajnfSmXFc S1Emft+6B1zJzjflHmu3bV1Gm4dQkz0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1687878855; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mvvSdpXIedbTXAbSb7UutGw61tF99/DRU3/HmEFE0S8=; b=2tZ/yMfoUhSuwsDX/BM+NJW+VydkvQ5PE5uPR3m3GcdMY5SODIs2zREa/sc9bPl/3Iy6zp S9pY9tAFX3WQgEDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 947B413276; Tue, 27 Jun 2023 15:14:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2KEzJMf8mmQuJQAAMHmgww (envelope-from ); Tue, 27 Jun 2023 15:14:15 +0000 From: Martin Jambor To: Jan Hubicka , aldyh@redhat.com, amacleod@redhat.com, jwakely@redhat.com Cc: gcc-patches@gcc.gnu.org Subject: Re: Enable ranger for ipa-prop In-Reply-To: References: User-Agent: Notmuch/0.37 (https://notmuchmail.org) Emacs/28.2 (x86_64-suse-linux-gnu) Date: Tue, 27 Jun 2023 17:14:15 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_SOFTFAIL,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 Tue, Jun 27 2023, 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? > > Honza > > gcc/ChangeLog: > > PR middle-end/110377 > * ipa-prop.cc (ipa_compute_jump_functions_for_edge): Add ranger > parameter; use ranger instance for rnage queries. > (ipa_compute_jump_functions_for_bb): Pass around ranger. > (analysis_dom_walker::before_dom_children): Enable ranger. Looks good to me (with or without passing a ranger parameter around). Martin > > gcc/testsuite/ChangeLog: > > PR middle-end/110377 > * gcc.dg/tree-ssa/pr110377.c: New test. > > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr110377.c b/gcc/testsuite/gcc.dg/tree-ssa/pr110377.c > new file mode 100644 > index 00000000000..cbe3441caea > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr110377.c > @@ -0,0 +1,16 @@ > +/* { dg-do compile */ > +/* { dg-options "-O2 -fdump-ipa-fnsummary" } */ > +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-tree-dump "-INF, 5-INF" "fnsummary" } } */ > diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc > index 41c812194ca..693d4805d93 100644 > --- a/gcc/ipa-prop.cc > +++ b/gcc/ipa-prop.cc > @@ -2341,7 +2341,8 @@ ipa_set_jfunc_vr (ipa_jump_func *jf, const ipa_vr &vr) > > static void > ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, > - struct cgraph_edge *cs) > + struct cgraph_edge *cs, > + gimple_ranger *ranger) > { > ipa_node_params *info = ipa_node_params_sum->get (cs->caller); > ipa_edge_args *args = ipa_edge_args_sum->get_create (cs); > @@ -2386,7 +2387,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 +2409,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) > + && ranger->range_of_expr (vr, arg, cs->call_stmt) > && !vr.undefined_p ()) > { > Value_Range resvr (vr); > @@ -2517,7 +2518,8 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, > from BB. */ > > static void > -ipa_compute_jump_functions_for_bb (struct ipa_func_body_info *fbi, basic_block bb) > +ipa_compute_jump_functions_for_bb (struct ipa_func_body_info *fbi, basic_block bb, > + gimple_ranger *ranger) > { > struct ipa_bb_info *bi = ipa_get_bb_info (fbi, bb); > int i; > @@ -2536,7 +2538,7 @@ ipa_compute_jump_functions_for_bb (struct ipa_func_body_info *fbi, basic_block b > && !gimple_call_fnspec (cs->call_stmt).known_p ()) > continue; > } > - ipa_compute_jump_functions_for_edge (fbi, cs); > + ipa_compute_jump_functions_for_edge (fbi, cs, ranger); > } > } > > @@ -3110,19 +3112,27 @@ class analysis_dom_walker : public dom_walker > { > public: > analysis_dom_walker (struct ipa_func_body_info *fbi) > - : dom_walker (CDI_DOMINATORS), m_fbi (fbi) {} > + : dom_walker (CDI_DOMINATORS), m_fbi (fbi) > + { > + m_ranger = enable_ranger (cfun, false); > + } > + ~analysis_dom_walker () > + { > + disable_ranger (cfun); > + } > > edge before_dom_children (basic_block) final override; > > private: > struct ipa_func_body_info *m_fbi; > + gimple_ranger *m_ranger; > }; > > edge > analysis_dom_walker::before_dom_children (basic_block bb) > { > ipa_analyze_params_uses_in_bb (m_fbi, bb); > - ipa_compute_jump_functions_for_bb (m_fbi, bb); > + ipa_compute_jump_functions_for_bb (m_fbi, bb, m_ranger); > return NULL; > } >