From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60825 invoked by alias); 23 Nov 2017 12:49:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 57171 invoked by uid 89); 23 Nov 2017 12:49:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Clients X-HELO: mail-wm0-f50.google.com Received: from mail-wm0-f50.google.com (HELO mail-wm0-f50.google.com) (74.125.82.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Nov 2017 12:49:08 +0000 Received: by mail-wm0-f50.google.com with SMTP id y80so16315843wmd.0 for ; Thu, 23 Nov 2017 04:49:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tn4ut5YfKUyoQlx9T5G48vZZT3JQ/zuoZlTMJSCZa3c=; b=RoWF9AEtS2oK9HseaQSVZ/6KoOV5nNzDwr+YRa+0SuyXnVhGL5KTzmRCO4a0E+RKd4 paLi1LpIS2vxu6j6OOYWakO6An60OTzqLx//FQmG+d0UiAKCNlZ2WjP3ja/sXwD+qaUZ 8VifuMYEbAh/gIM73i8Mg+rMMMKNPVo31L73MbBXlIfjlea+pUnqmMmU2hiZJYCrnXri LIzbIw7MOHU1G/Y5IEWVSWWaYRXzYSXWZyt2I8KIKMDKCjiELtS6ta/3xPsq3NfjY4km vrMGU3NF6FB9mVuk9GI3ZmGPtaktglozPjvzrvOVGKuToetqyYeTr1XT4GUGWEGwO8Ga uNmA== X-Gm-Message-State: AJaThX5pXH5ux5uc5KKhpG8CXPCoJYxI1W8HrLfJy/pvvuPeHdPowAO0 V83G+ueFTP36jZph9EEzjYLYzSn/yPXmv9GRBz0= X-Google-Smtp-Source: AGs4zMbVZx48Dqi86flXZPb5kQFgOOn7/BEq8+tzekmE+MQ/c55o6Pe7eXP2Az/8kghAs3JRPMrnS+a5D4h5Wkz2QWQ= X-Received: by 10.80.194.194 with SMTP id u2mr11016101edf.260.1511441346770; Thu, 23 Nov 2017 04:49:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.143.34 with HTTP; Thu, 23 Nov 2017 04:49:06 -0800 (PST) In-Reply-To: <80038401-a229-aba2-712d-1082aaa39b65@redhat.com> References: <80038401-a229-aba2-712d-1082aaa39b65@redhat.com> From: Richard Biener Date: Thu, 23 Nov 2017 13:14:00 -0000 Message-ID: Subject: Re: [RFA][PATCH] Use SCEV conditionally within vr-values and evrp range analysis To: Jeff Law Cc: gcc-patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-11/txt/msg02127.txt.bz2 On Thu, Nov 23, 2017 at 1:16 AM, Jeff Law wrote: > > Clients of the evrp range analysis may not have initialized the SCEV > infrastructure, and in fact my not want to (DOM for example). > > Yet inside both vr-values.c and gimple-ssa-evrp-analyze.c we have calls > into SCEV (that will fault/abort if SCEV is not properly initialized). > > This patch allows clients of vr-values.c and gimple-ssa-evrp-analyze.c > to indicate if they want SCEV analysis. > > Bootstrapped and regression tested by itself as well as with the DOM > patches to use EVRP analysis (which test the "don't want SCEV path). > > OK for the trunk? There's also scev_initialized_p () which you could conveniently use. Richard. > > Jeff > > * gimple-ssa-evrp-analyze.h (class evrp_range_analyzer): New data > member USE_SCEV. > * gimple-ssa-evrp-analyze.c > (evrp_range_analyzer::evrp_range_analyzer): Add new use_scev argument. > Pass it to the vr_values ctor. > (evrp_range_analyzer::record_ranges_from_phis): Conditionally use > SCEV to refine ranges for PHIs. > * gimple-ssa-evrp (evrp_dom_walker::evrp_dom_walker): Ask for > SCEV analysis in the vr-values engine. > * vr-values.h (class vr_values): New data meber USE_SCEV. > * vr-values.c (vr_values::vr_values): Add new use_scev argument. > (vr_values::extract_range_from_phi_node): Conditionally use > SCEV to refine ranges for PHIs. > > > diff --git a/gcc/gimple-ssa-evrp-analyze.c b/gcc/gimple-ssa-evrp-analyze.c > index 68a2cdc..bc41be1 100644 > --- a/gcc/gimple-ssa-evrp-analyze.c > +++ b/gcc/gimple-ssa-evrp-analyze.c > @@ -42,7 +42,8 @@ along with GCC; see the file COPYING3. If not see > #include "vr-values.h" > #include "gimple-ssa-evrp-analyze.h" > > -evrp_range_analyzer::evrp_range_analyzer () : stack (10) > +evrp_range_analyzer::evrp_range_analyzer (bool use_scev_) > + : vr_values (use_scev_), stack (10), use_scev (use_scev_) > { > edge e; > edge_iterator ei; > @@ -176,7 +177,8 @@ evrp_range_analyzer::record_ranges_from_phis (basic_block bb) > to use VARYING for them. But we can still resort to > SCEV for loop header PHIs. */ > struct loop *l; > - if (interesting > + if (use_scev > + && interesting > && (l = loop_containing_stmt (phi)) > && l->header == gimple_bb (phi)) > vr_values.adjust_range_with_scev (&vr_result, l, phi, lhs); > @@ -341,3 +343,4 @@ evrp_range_analyzer::pop_value_range (tree var) > stack.pop (); > return vr; > } > + > diff --git a/gcc/gimple-ssa-evrp-analyze.h b/gcc/gimple-ssa-evrp-analyze.h > index 3d64c50..18f5b8c 100644 > --- a/gcc/gimple-ssa-evrp-analyze.h > +++ b/gcc/gimple-ssa-evrp-analyze.h > @@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see > class evrp_range_analyzer > { > public: > - evrp_range_analyzer (void); > + evrp_range_analyzer (bool); > ~evrp_range_analyzer (void) { stack.release (); } > > void enter (basic_block); > @@ -65,6 +65,9 @@ class evrp_range_analyzer > > /* STACK holds the old VR. */ > auto_vec > stack; > + > + /* Whether or not to use SCEV to refine ranges. */ > + bool use_scev; > }; > > #endif /* GCC_GIMPLE_SSA_EVRP_ANALYZE_H */ > diff --git a/gcc/gimple-ssa-evrp.c b/gcc/gimple-ssa-evrp.c > index f56d67f..13e4e16 100644 > --- a/gcc/gimple-ssa-evrp.c > +++ b/gcc/gimple-ssa-evrp.c > @@ -69,6 +69,7 @@ class evrp_dom_walker : public dom_walker > public: > evrp_dom_walker () > : dom_walker (CDI_DOMINATORS), > + evrp_range_analyzer (true), > evrp_folder (evrp_range_analyzer.get_vr_values ()) > { > need_eh_cleanup = BITMAP_ALLOC (NULL); > diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c > index 838822d..46be749 100644 > --- a/gcc/tree-vrp.c > +++ b/gcc/tree-vrp.c > @@ -4737,6 +4737,7 @@ insert_range_assertions (void) > class vrp_prop : public ssa_propagation_engine > { > public: > + vrp_prop (bool use_scev_) : vr_values (use_scev_) { } > enum ssa_prop_result visit_stmt (gimple *, edge *, tree *) FINAL OVERRIDE; > enum ssa_prop_result visit_phi (gphi *) FINAL OVERRIDE; > > @@ -6862,7 +6863,7 @@ execute_vrp (bool warn_array_bounds_p) > /* For visiting PHI nodes we need EDGE_DFS_BACK computed. */ > mark_dfs_back_edges (); > > - class vrp_prop vrp_prop; > + class vrp_prop vrp_prop (true); > vrp_prop.vrp_initialize (); > vrp_prop.ssa_propagate (); > vrp_prop.vrp_finalize (warn_array_bounds_p); > diff --git a/gcc/vr-values.c b/gcc/vr-values.c > index 2d11861..54b0be5 100644 > --- a/gcc/vr-values.c > +++ b/gcc/vr-values.c > @@ -1907,7 +1907,8 @@ vr_values::dump_all_value_ranges (FILE *file) > > /* Initialize VRP lattice. */ > > -vr_values::vr_values () : vrp_value_range_pool ("Tree VRP value ranges") > +vr_values::vr_values (bool use_scev_) > + : vrp_value_range_pool ("Tree VRP value ranges"), use_scev (use_scev_) > { > values_propagated = false; > num_vr_values = num_ssa_names; > @@ -2935,7 +2936,8 @@ scev_check: > scev_check can be reached from two paths, one is a fall through from above > "varying" label, the other is direct goto from code block which tries to > avoid infinite simulation. */ > - if ((l = loop_containing_stmt (phi)) > + if (use_scev > + && (l = loop_containing_stmt (phi)) > && l->header == gimple_bb (phi)) > adjust_range_with_scev (vr_result, l, phi, lhs); > > diff --git a/gcc/vr-values.h b/gcc/vr-values.h > index 124ee6f..bfeb1e4 100644 > --- a/gcc/vr-values.h > +++ b/gcc/vr-values.h > @@ -37,7 +37,7 @@ along with GCC; see the file COPYING3. If not see > class vr_values > { > public: > - vr_values (void); > + vr_values (bool); > ~vr_values (void); > > value_range *get_value_range (const_tree); > @@ -115,6 +115,9 @@ class vr_values > /* Allocations for equivalences all come from this obstack. */ > bitmap_obstack vrp_equiv_obstack; > > + /* Whether or not to use SCEV to refine ranges. */ > + bool use_scev; > + > /* Value range array. After propagation, VR_VALUE[I] holds the range > of values that SSA name N_I may take. */ > unsigned int num_vr_values; >