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 99EFC3858413 for ; Mon, 31 Jul 2023 16:47:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99EFC3858413 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 B857821B92; Mon, 31 Jul 2023 16:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1690822065; 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=oZv4DM+SkyJTlJ7C7Lw41HuQqGs7ZJoxyVjhBpNrXYs=; b=Q/LSk5fnoIYvzM+PVpwScpcfvsqFbOs0xw4Wfgz/dcx+fZnQsD2m88QGJdwmtb501tYYvZ plgMqtr7i1aw2JQeo5w5cu3Q080vuBUqj8wLuwyHb28lMl+4KBymt4j1z2hpWyjAS7TnsI q03mzG9pBAOLLUvav4gMTbGnisKRKMY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1690822065; 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=oZv4DM+SkyJTlJ7C7Lw41HuQqGs7ZJoxyVjhBpNrXYs=; b=1KVyL7wFWac1xRMSXXmNjiYuG8NPB4wAIiINgP4XM0HWnevSSnWbqh9tduzm2Mrbek9ekd iEs9sVh74rNzvGBw== 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 A73381322C; Mon, 31 Jul 2023 16:47:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id lS49KLHlx2TFHAAAMHmgww (envelope-from ); Mon, 31 Jul 2023 16:47:45 +0000 From: Martin Jambor To: Aldy Hernandez , GCC patches Cc: Andrew MacLeod Subject: Re: [PATCH] Read global value/mask in IPA. In-Reply-To: References: <20230717131411.330650-1-aldyh@redhat.com> User-Agent: Notmuch/0.37 (https://notmuchmail.org) Emacs/28.2 (x86_64-suse-linux-gnu) Date: Mon, 31 Jul 2023 18:47:45 +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: Hello, On Tue, Jul 18 2023, Aldy Hernandez wrote: > On 7/17/23 15:14, Aldy Hernandez wrote: >> Instead of reading the known zero bits in IPA, read the value/mask >> pair which is available. >> >> There is a slight change of behavior here. I have removed the check >> for SSA_NAME, as the ranger can calculate the range and value/mask for >> INTEGER_CST. This simplifies the code a bit, since there's no special >> casing when setting the jfunc bits. The default range for VR is >> undefined, so I think it's safe just to check for undefined_p(). > > Final round of tests revealed a regression for which I've adjusted the > testcase. > > It turns out g++.dg/ipa/pure-const-3.C fails because IPA can now pick up > value/mask from any pass that has an integrated ranger. The test was > previously disabling evrp and CCP, but now VRP[12], jump threading, and > DOM can make value/mask adjustments visible to IPA so they must be > disabled as well. So can this be then converted into a new testcase that would test that we can now derive something we could not in the past? The patch is OK (but the testcase above is highly desirable). Thanks for keeping looking at IPA-VR. Martin > > We've run into these scenarios multiple times in the past-- any > improvements to the ranger pipeline causes everyone to get smarter, > making changes visible earlier in the pipeline. > > Aldy > From e1dfd4d6b3d3bf09d55b6ea3ac732462c7030802 Mon Sep 17 00:00:00 2001 > From: Aldy Hernandez > Date: Fri, 14 Jul 2023 12:38:16 +0200 > Subject: [PATCH] Read global value/mask in IPA. > > Instead of reading the known zero bits in IPA, read the value/mask > pair which is available. > > There is a slight change of behavior here. I have removed the check > for SSA_NAME, as the ranger can calculate the range and value/mask for > INTEGER_CST. This simplifies the code a bit, since there's no special > casing when setting the jfunc bits. The default range for VR is > undefined, so I think it's safe just to check for undefined_p(). > > gcc/ChangeLog: > > * ipa-prop.cc (ipa_compute_jump_functions_for_edge): Read global > value/mask. > > gcc/testsuite/ChangeLog: > > * g++.dg/ipa/pure-const-3.C: Adjust for smarter value/mask being > read by ranger earlier than expected by test. > --- > gcc/ipa-prop.cc | 18 ++++++++---------- > gcc/testsuite/g++.dg/ipa/pure-const-3.C | 2 +- > 2 files changed, 9 insertions(+), 11 deletions(-) > > diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc > index 5d790ff1265..4f6ed7b89bd 100644 > --- a/gcc/ipa-prop.cc > +++ b/gcc/ipa-prop.cc > @@ -2402,8 +2402,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, > } > else > { > - if (TREE_CODE (arg) == SSA_NAME > - && param_type > + if (param_type > && Value_Range::supports_type_p (TREE_TYPE (arg)) > && Value_Range::supports_type_p (param_type) > && irange::supports_p (TREE_TYPE (arg)) > @@ -2422,15 +2421,14 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, > gcc_assert (!jfunc->m_vr); > } > > - if (INTEGRAL_TYPE_P (TREE_TYPE (arg)) > - && (TREE_CODE (arg) == SSA_NAME || TREE_CODE (arg) == INTEGER_CST)) > + if (INTEGRAL_TYPE_P (TREE_TYPE (arg)) && !vr.undefined_p ()) > { > - if (TREE_CODE (arg) == SSA_NAME) > - ipa_set_jfunc_bits (jfunc, 0, > - widest_int::from (get_nonzero_bits (arg), > - TYPE_SIGN (TREE_TYPE (arg)))); > - else > - ipa_set_jfunc_bits (jfunc, wi::to_widest (arg), 0); > + irange &r = as_a (vr); > + irange_bitmask bm = r.get_bitmask (); > + signop sign = TYPE_SIGN (TREE_TYPE (arg)); > + ipa_set_jfunc_bits (jfunc, > + widest_int::from (bm.value (), sign), > + widest_int::from (bm.mask (), sign)); > } > else if (POINTER_TYPE_P (TREE_TYPE (arg))) > { > diff --git a/gcc/testsuite/g++.dg/ipa/pure-const-3.C b/gcc/testsuite/g++.dg/ipa/pure-const-3.C > index b4a4673e86e..e43cf09af27 100644 > --- a/gcc/testsuite/g++.dg/ipa/pure-const-3.C > +++ b/gcc/testsuite/g++.dg/ipa/pure-const-3.C > @@ -1,5 +1,5 @@ > /* { dg-do compile } */ > -/* { dg-options "-O2 -fno-ipa-vrp -fdump-tree-optimized -fno-tree-ccp -fdisable-tree-evrp" } */ > +/* { dg-options "-O2 -fno-ipa-vrp -fdump-tree-optimized -fno-tree-ccp -fdisable-tree-evrp -fdisable-tree-vrp1 -fdisable-tree-vrp2 -fno-thread-jumps -fno-tree-dominator-opts" } */ > int *ptr; > static int barvar; > static int b(int a); > -- > 2.40.1