From patchwork Fri Jul 22 12:27:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 72620 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp970632qga; Fri, 22 Jul 2016 05:27:53 -0700 (PDT) X-Received: by 10.66.8.37 with SMTP id o5mr6127936paa.100.1469190472940; Fri, 22 Jul 2016 05:27:52 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u29si15699112pfi.159.2016.07.22.05.27.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jul 2016 05:27:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-432304-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-432304-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-432304-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=XJi1vU1Y1vIWvnPEJ CGARqc8i+ovCVzBW4TZcC6zkwkkN8N9SWh3izKFnt0nzh3tTjWTf2NxFQUX6SLxj aidbTDzOkgcQb5loVi9Umudg1dS+IzAHhBE6AKvlyOv7geEuDAJ9gM2IfzRoSHhh 855MOzz8i+x/usm4C9iqkJkIkk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=Dudk+Na47t3koFgZN/ExdC7 r6nQ=; b=Xymc6EOCGeBeUn9NtPmLIjr+mSOmscA3Y5jycEC7M1ziXGVm9maovvY Wxn2GwrDvCPhx5dlicdJbCE07/biDNP2bnG4EIYTV/obqjWEShjBGk/cs30Ex5Ig oHcgecMHMFhat2LSZB2BUXgEuo0UROtXXtTts2XbvEMHh6zBmAhc= Received: (qmail 25599 invoked by alias); 22 Jul 2016 12:27:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 24359 invoked by uid 89); 22 Jul 2016 12:27:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:tree_co, sk:compare, combined_fn, 83, 6 X-HELO: mail-pf0-f175.google.com Received: from mail-pf0-f175.google.com (HELO mail-pf0-f175.google.com) (209.85.192.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 22 Jul 2016 12:27:29 +0000 Received: by mail-pf0-f175.google.com with SMTP id h186so41128267pfg.3 for ; Fri, 22 Jul 2016 05:27:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=C54k+SrCqfS7iOlswRrRYQ9pUWgjXO+x5cxouZScGOs=; b=iXlIdxGDnSr8uXqgA8LX0ocnc7CaSQjzTSjw0i54YofZhOIxk82A15v8HfaQgsTkp4 Fvl0R+eSeOZM8Wmj3mhtWJV5NDEtqY+5YPbR8XiYtxjYdkQiecl5y5s4tPNLM0waQ1FF uwbPmIO2hUbLt0oXeFdSsU2R+ECsDYyGzKImE7XED7ncdeX0vAJUP+z5/Exeeu19B1I7 AtvB0WOMjiSKpDOobcR48zDr/g4n0feKQZBdr2bqlk7rJlclPBHfkTZgtHB6kGng0dSM Uilk6ht4rWohhtYN+RHulVeBQJqYtEHDS23rEMk63mz8sw3VIiBEpkdI3EsllL+L7L+q 9ubw== X-Gm-Message-State: AEkoouu0WXkhynyaeX/e7p+wS3YRjtwKlqSulsWwvGaA8gIl0VBvpm/gpoLYBY75Xrg1Ck7A X-Received: by 10.98.205.6 with SMTP id o6mr5884640pfg.37.1469190447479; Fri, 22 Jul 2016 05:27:27 -0700 (PDT) Received: from [10.1.1.19] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.gmail.com with ESMTPSA id s89sm19767114pfi.83.2016.07.22.05.27.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jul 2016 05:27:26 -0700 (PDT) Subject: Re: [RFC][IPA-VRP] Re-factor tree-vrp to factor out common code To: "gcc-patches@gcc.gnu.org" References: <57886949.8010300@linaro.org> <57886A2A.4070703@linaro.org> Cc: Richard Biener , Jan Hubicka , Martin Jambor From: kugan Message-ID: <21d3ea50-a799-0b5b-4736-3beeca7860c4@linaro.org> Date: Fri, 22 Jul 2016 22:27:10 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <57886A2A.4070703@linaro.org> X-IsSubscribed: yes Hi, Now that early vrp is moved as part of tree-vrp, there is only minimal interface tree-vrp should expose for ipa-vrp. However, I have not found the right place to place struct value_range (with GTY marker) and enum value_range_type. enum value_range_type is needed in tree-ssanames.[h|c] and in all the places where get|set_range_info is used. struct value_range is needed in ipa-prop.h, therefore all the places ipa-prop.h is included. One option is to place it in tree-vrp.h and expose this to GTY infrastructure. Then include it in all the places we need any of these types. It is in lots of c files. I have now placed both in tree.h. Even though that compiles, I am not convinced that is the right place. I would appreciate comment/preferences in this regard. I am also attaching the current version of this patch for review. I will update it based on the comments. Thanks, Kugan >From 2e7d10923fefddafdeffc571e870508ac0ee193c Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Tue, 21 Jun 2016 12:42:44 +1000 Subject: [PATCH 4/7] Refactor vrp --- gcc/tree-ssanames.h | 5 ----- gcc/tree-vrp.c | 50 ++++++++++++-------------------------------------- gcc/tree-vrp.h | 23 +++++++++++++++++++++++ gcc/tree.h | 31 +++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 43 deletions(-) create mode 100644 gcc/tree-vrp.h diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h index c81b1a1..8e66ce6 100644 --- a/gcc/tree-ssanames.h +++ b/gcc/tree-ssanames.h @@ -62,11 +62,6 @@ struct GTY ((variable_size)) range_info_def { #define num_ssa_names (vec_safe_length (cfun->gimple_df->ssa_names)) #define ssa_name(i) ((*cfun->gimple_df->ssa_names)[(i)]) - -/* Type of value ranges. See value_range_d In tree-vrp.c for a - description of these types. */ -enum value_range_type { VR_UNDEFINED, VR_RANGE, VR_ANTI_RANGE, VR_VARYING }; - /* Sets the value range to SSA. */ extern void set_range_info (tree, enum value_range_type, const wide_int_ref &, const wide_int_ref &); diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index edaacf2..a318d39 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -59,32 +59,7 @@ along with GCC; see the file COPYING3. If not see #include "target.h" #include "case-cfn-macros.h" #include "alloc-pool.h" - -/* Range of values that can be associated with an SSA_NAME after VRP - has executed. */ -struct value_range -{ - /* Lattice value represented by this range. */ - enum value_range_type type; - - /* Minimum and maximum values represented by this range. These - values should be interpreted as follows: - - - If TYPE is VR_UNDEFINED or VR_VARYING then MIN and MAX must - be NULL. - - - If TYPE == VR_RANGE then MIN holds the minimum value and - MAX holds the maximum value of the range [MIN, MAX]. - - - If TYPE == ANTI_RANGE the variable is known to NOT - take any values in the range [MIN, MAX]. */ - tree min; - tree max; - - /* Set of SSA names whose value ranges are equivalent to this one. - This set is only valid when TYPE is VR_RANGE or VR_ANTI_RANGE. */ - bitmap equiv; -}; +#include "tree-vrp.h" #define VR_INITIALIZER { VR_UNDEFINED, NULL_TREE, NULL_TREE, NULL } @@ -108,8 +83,6 @@ live_on_edge (edge e, tree name) /* Local functions. */ static int compare_values (tree val1, tree val2); static int compare_values_warnv (tree val1, tree val2, bool *); -static void vrp_meet (value_range *, value_range *); -static void vrp_intersect_ranges (value_range *, value_range *); static tree vrp_evaluate_conditional_warnv_with_ops (enum tree_code, tree, tree, bool, bool *, bool *); @@ -4605,7 +4578,7 @@ compare_range_with_value (enum tree_code comp, value_range *vr, tree val, /* Debugging dumps. */ -void dump_value_range (FILE *, value_range *); +void dump_value_range (FILE *, const value_range *); void debug_value_range (value_range *); void dump_all_value_ranges (FILE *); void debug_all_value_ranges (void); @@ -4616,7 +4589,7 @@ void debug_vr_equiv (bitmap); /* Dump value range VR to FILE. */ void -dump_value_range (FILE *file, value_range *vr) +dump_value_range (FILE *file, const value_range *vr) { if (vr == NULL) fprintf (file, "[]"); @@ -8447,7 +8420,7 @@ intersect_ranges (enum value_range_type *vr0type, /* Intersect the two value-ranges *VR0 and *VR1 and store the result in *VR0. This may not be the smallest possible such range. */ -static void +void vrp_intersect_ranges_1 (value_range *vr0, value_range *vr1) { value_range saved; @@ -8499,7 +8472,7 @@ vrp_intersect_ranges_1 (value_range *vr0, value_range *vr1) bitmap_copy (vr0->equiv, vr1->equiv); } -static void +void vrp_intersect_ranges (value_range *vr0, value_range *vr1) { if (dump_file && (dump_flags & TDF_DETAILS)) @@ -8524,7 +8497,7 @@ vrp_intersect_ranges (value_range *vr0, value_range *vr1) may not be the smallest possible such range. */ static void -vrp_meet_1 (value_range *vr0, value_range *vr1) +vrp_meet_1 (value_range *vr0, const value_range *vr1) { value_range saved; @@ -8596,8 +8569,8 @@ vrp_meet_1 (value_range *vr0, value_range *vr1) bitmap_clear (vr0->equiv); } -static void -vrp_meet (value_range *vr0, value_range *vr1) +void +vrp_meet (value_range *vr0, const value_range *vr1) { if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -10171,7 +10144,7 @@ finalize_jump_threads (void) /* Traverse all the blocks folding conditionals with known ranges. */ static void -vrp_finalize (bool warn_array_bounds_p) +vrp_finalize (bool jump_thread_p, bool warn_array_bounds_p) { size_t i; @@ -10212,7 +10185,8 @@ vrp_finalize (bool warn_array_bounds_p) /* We must identify jump threading opportunities before we release the datastructures built by VRP. */ - identify_jump_threads (); + if (jump_thread_p) + identify_jump_threads (); /* Free allocated memory. */ free (vr_value); @@ -10296,7 +10270,7 @@ execute_vrp (bool warn_array_bounds_p) vrp_initialize (); ssa_propagate (vrp_visit_stmt, vrp_visit_phi_node); - vrp_finalize (warn_array_bounds_p); + vrp_finalize (true, warn_array_bounds_p); free_numbers_of_iterations_estimates (cfun); diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h new file mode 100644 index 0000000..38aacf5 --- /dev/null +++ b/gcc/tree-vrp.h @@ -0,0 +1,23 @@ +/* Support routines for Value Range Propagation (VRP). + Copyright (C) Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +extern void vrp_intersect_ranges (value_range *vr0, value_range *vr1); +extern void vrp_meet (value_range *vr0, const value_range *vr1); +extern void dump_value_range (FILE *, const value_range *); + diff --git a/gcc/tree.h b/gcc/tree.h index 90413fc..8fc4f4f 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -230,6 +230,37 @@ as_internal_fn (combined_fn code) #define TREE_CODE_LENGTH(CODE) tree_code_length[(int) (CODE)] +/* Type of value ranges. See value_range_d In tree-vrp.c for a + description of these types. */ +enum value_range_type { VR_UNDEFINED, VR_RANGE, + VR_ANTI_RANGE, VR_VARYING, VR_LAST }; + +/* Range of values that can be associated with an SSA_NAME after VRP + has executed. */ +struct GTY(()) value_range +{ + /* Lattice value represented by this range. */ + enum value_range_type type; + + /* Minimum and maximum values represented by this range. These + values should be interpreted as follows: + + - If TYPE is VR_UNDEFINED or VR_VARYING then MIN and MAX must + be NULL. + + - If TYPE == VR_RANGE then MIN holds the minimum value and + MAX holds the maximum value of the range [MIN, MAX]. + + - If TYPE == ANTI_RANGE the variable is known to NOT + take any values in the range [MIN, MAX]. */ + tree min; + tree max; + + /* Set of SSA names whose value ranges are equivalent to this one. + This set is only valid when TYPE is VR_RANGE or VR_ANTI_RANGE. */ + bitmap equiv; +}; + /* Helper macros for math builtins. */ -- 1.9.1