From patchwork Thu Oct 21 13:31:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 46494 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 244493857800 for ; Thu, 21 Oct 2021 13:33:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 244493857800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634823235; bh=P+Zhj3RQIznik30KRzsDX7W/cV/4/SHvKXzYp5qfv8I=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=KExX+4cmTGK+ZzE5DUnGLHqKxWlavxRPZ5t/zZfJBa3zrFqAfjQBxGLGhppQa2SP9 k1XBSJ1bFS+wdletiSjvXl/uIJOiNhXQ4siJVGEYPuMuyWdhKpgdCazcMLJ1YhwYHc ZZYSP2ALG4pwOfSmRn9TzTU+/Pshg1Fi+gaej77Y= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id F196C3857C7F for ; Thu, 21 Oct 2021 13:31:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F196C3857C7F Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-pt6FaEwMP9-dv6EUFugqiA-1; Thu, 21 Oct 2021 09:31:42 -0400 X-MC-Unique: pt6FaEwMP9-dv6EUFugqiA-1 Received: by mail-qv1-f69.google.com with SMTP id ey7-20020a0562140b6700b00382cf3eb480so881917qvb.22 for ; Thu, 21 Oct 2021 06:31:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language; bh=P+Zhj3RQIznik30KRzsDX7W/cV/4/SHvKXzYp5qfv8I=; b=hqN6oQbGP30fo7TlvoYd9cr2TcgrrKYV4GmMsDKntmT8o7p+4Ym8iPwmiWPuogrYVc JzMKVIdiol3NGFoNUVBzXFbe3K9nf0aupFUI+OOnZLA2b2PC8eUXBxcM6XrenUfe4Pl4 qceRI0SFgmkbvrVcaypqpyhTh/Bnv726kf4f+iexnR3WwyvqWpxb0a6ndv6o/f1U8F2T XReyXMNZqAPtSVUcoUUHs8aZ1nsq78kAdRLMYB3NpSN6INjghzRyqK8E3VaDLrsoEgaW Xb91/oFPDiasqwCtiIGe4begSjoom/IDvrd64aiw6KrhB+6knmVlRbkiUXWGURr275Rw 0sOA== X-Gm-Message-State: AOAM532IC7z3IhN4wzfmfxZgV+xcJTIj0g1du8QfEE70YjWSVWs4wlTO cFcqAy8WELxRDfT2yoFpUfvYGwTgCft9PtJCwU8X0EGlzmqhcQ3ONck/lFTNU3looij14hQEmRD OjnmC3k8BGZ5VzhXUPQ== X-Received: by 2002:a37:a050:: with SMTP id j77mr4437237qke.337.1634823101657; Thu, 21 Oct 2021 06:31:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj/hgnuF9K/xu4cis8EEqHPalKwKQgSH7rN217PQF5aoXrRJCvhXuhaYg6o1wmaB3KYUcQ1w== X-Received: by 2002:a37:a050:: with SMTP id j77mr4437207qke.337.1634823101381; Thu, 21 Oct 2021 06:31:41 -0700 (PDT) Received: from ?IPv6:2607:fea8:a262:5f00::38cf? ([2607:fea8:a262:5f00::38cf]) by smtp.gmail.com with ESMTPSA id q8sm2762128qkl.2.2021.10.21.06.31.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Oct 2021 06:31:40 -0700 (PDT) To: gcc-patches Subject: [COMMITED 1/3] Move ranger only VRP folder to tree-vrp. Message-ID: <2111c3f5-1ba3-963d-6703-f97ae6a748df@redhat.com> Date: Thu, 21 Oct 2021 09:31:38 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch moves the ranger rvrp folder class to tree-vrp.c, and provides an execute_ranger_vrp() routine that matches the same parameter sequence as the execute_vrp() routine has.  The evrp pass is tweaked to call this routine when running in ranger-only mode. This paves the way for a ranger version of VRP to be instantiated. There is no functional change. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. From 434ebc1e08b1d83ecd3622ee2a3c7270869bda52 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 15 Oct 2021 12:26:13 -0400 Subject: [PATCH 1/3] Move ranger only VRP folder to tree-vrp. Consolidate the RVRP folder into a single "execute_vrp" routine that mimics the format used by the vrp1 and vrp2 passes. Relocate into the tree-vrp file. * gimple-ssa-evrp.c (class rvrp_folder): Move to tree-vrp.c. (execute_early_vrp): For ranger only mode, invoke ranger_vrp. * tree-vrp.c (class rvrp_folder): Relocate here. (execute_ranger_vrp): New. * tree-vrp.h (execute_ranger_vrp): Export. --- gcc/gimple-ssa-evrp.c | 92 ++----------------------------- gcc/tree-vrp.c | 122 ++++++++++++++++++++++++++++++++++++++++++ gcc/tree-vrp.h | 2 + 3 files changed, 128 insertions(+), 88 deletions(-) diff --git a/gcc/gimple-ssa-evrp.c b/gcc/gimple-ssa-evrp.c index 7f2055501a0..a0192e2b2aa 100644 --- a/gcc/gimple-ssa-evrp.c +++ b/gcc/gimple-ssa-evrp.c @@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-range.h" #include "fold-const.h" #include "value-pointer-equiv.h" +#include "tree-vrp.h" // This is the classic EVRP folder which uses a dominator walk and pushes // ranges into the next block if it is a single predecessor block. @@ -110,88 +111,6 @@ protected: simplify_using_ranges simplifier; }; -// This is a ranger based folder which continues to use the dominator -// walk to access the substitute and fold machinery. Ranges are calculated -// on demand. - -class rvrp_folder : public substitute_and_fold_engine -{ -public: - - rvrp_folder () : substitute_and_fold_engine (), m_simplifier () - { - m_ranger = enable_ranger (cfun); - m_simplifier.set_range_query (m_ranger, m_ranger->non_executable_edge_flag); - m_pta = new pointer_equiv_analyzer (m_ranger); - } - - ~rvrp_folder () - { - if (dump_file && (dump_flags & TDF_DETAILS)) - m_ranger->dump (dump_file); - - m_ranger->export_global_ranges (); - disable_ranger (cfun); - delete m_pta; - } - - tree value_of_expr (tree name, gimple *s = NULL) OVERRIDE - { - // Shortcircuit subst_and_fold callbacks for abnormal ssa_names. - if (TREE_CODE (name) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name)) - return NULL; - tree ret = m_ranger->value_of_expr (name, s); - if (!ret && supported_pointer_equiv_p (name)) - ret = m_pta->get_equiv (name); - return ret; - } - - tree value_on_edge (edge e, tree name) OVERRIDE - { - // Shortcircuit subst_and_fold callbacks for abnormal ssa_names. - if (TREE_CODE (name) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name)) - return NULL; - tree ret = m_ranger->value_on_edge (e, name); - if (!ret && supported_pointer_equiv_p (name)) - ret = m_pta->get_equiv (name); - return ret; - } - - tree value_of_stmt (gimple *s, tree name = NULL) OVERRIDE - { - // Shortcircuit subst_and_fold callbacks for abnormal ssa_names. - if (TREE_CODE (name) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name)) - return NULL; - return m_ranger->value_of_stmt (s, name); - } - - void pre_fold_bb (basic_block bb) OVERRIDE - { - m_pta->enter (bb); - } - - void post_fold_bb (basic_block bb) OVERRIDE - { - m_pta->leave (bb); - } - - void pre_fold_stmt (gimple *stmt) OVERRIDE - { - m_pta->visit_stmt (stmt); - } - - bool fold_stmt (gimple_stmt_iterator *gsi) OVERRIDE - { - return m_simplifier.simplify (gsi); - } - -private: - DISABLE_COPY_AND_ASSIGN (rvrp_folder); - gimple_ranger *m_ranger; - simplify_using_ranges m_simplifier; - pointer_equiv_analyzer *m_pta; -}; - // In a hybrid folder, start with an EVRP folder, and add the required // fold_stmt bits to either try the ranger first or second. // @@ -393,6 +312,9 @@ hybrid_folder::choose_value (tree evrp_val, tree ranger_val) static unsigned int execute_early_vrp () { + if ((param_evrp_mode & EVRP_MODE_RVRP_FIRST) == EVRP_MODE_RVRP_ONLY) + return execute_ranger_vrp (cfun, false); + /* Ideally this setup code would move into the ctor for the folder However, this setup can change the number of blocks which invalidates the internal arrays that are set up by the dominator @@ -411,12 +333,6 @@ execute_early_vrp () folder.substitute_and_fold (); break; } - case EVRP_MODE_RVRP_ONLY: - { - rvrp_folder folder; - folder.substitute_and_fold (); - break; - } case EVRP_MODE_EVRP_FIRST: { hybrid_folder folder (true); diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index c24c67f8874..b0b217bbf86 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-array-bounds.h" #include "gimple-range.h" #include "gimple-range-path.h" +#include "value-pointer-equiv.h" /* Set of SSA names found live during the RPO traversal of the function for still active basic-blocks. */ @@ -4313,6 +4314,127 @@ execute_vrp (struct function *fun, bool warn_array_bounds_p) return 0; } +// This is a ranger based folder which continues to use the dominator +// walk to access the substitute and fold machinery. Ranges are calculated +// on demand. + +class rvrp_folder : public substitute_and_fold_engine +{ +public: + + rvrp_folder (gimple_ranger *r) : substitute_and_fold_engine (), + m_simplifier (r, r->non_executable_edge_flag) + { + m_ranger = r; + m_pta = new pointer_equiv_analyzer (m_ranger); + } + + ~rvrp_folder () + { + delete m_pta; + } + + tree value_of_expr (tree name, gimple *s = NULL) OVERRIDE + { + // Shortcircuit subst_and_fold callbacks for abnormal ssa_names. + if (TREE_CODE (name) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name)) + return NULL; + tree ret = m_ranger->value_of_expr (name, s); + if (!ret && supported_pointer_equiv_p (name)) + ret = m_pta->get_equiv (name); + return ret; + } + + tree value_on_edge (edge e, tree name) OVERRIDE + { + // Shortcircuit subst_and_fold callbacks for abnormal ssa_names. + if (TREE_CODE (name) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name)) + return NULL; + tree ret = m_ranger->value_on_edge (e, name); + if (!ret && supported_pointer_equiv_p (name)) + ret = m_pta->get_equiv (name); + return ret; + } + + tree value_of_stmt (gimple *s, tree name = NULL) OVERRIDE + { + // Shortcircuit subst_and_fold callbacks for abnormal ssa_names. + if (TREE_CODE (name) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name)) + return NULL; + return m_ranger->value_of_stmt (s, name); + } + + void pre_fold_bb (basic_block bb) OVERRIDE + { + m_pta->enter (bb); + } + + void post_fold_bb (basic_block bb) OVERRIDE + { + m_pta->leave (bb); + } + + void pre_fold_stmt (gimple *stmt) OVERRIDE + { + m_pta->visit_stmt (stmt); + } + + bool fold_stmt (gimple_stmt_iterator *gsi) OVERRIDE + { + return m_simplifier.simplify (gsi); + } + +private: + DISABLE_COPY_AND_ASSIGN (rvrp_folder); + gimple_ranger *m_ranger; + simplify_using_ranges m_simplifier; + pointer_equiv_analyzer *m_pta; +}; + +/* Main entry point for a VRP pass using just ranger. This can be called + from anywhere to perform a VRP pass, including from EVRP. */ + +unsigned int +execute_ranger_vrp (struct function *fun, bool warn_array_bounds_p) +{ + loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS); + rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa); + scev_initialize (); + calculate_dominance_info (CDI_DOMINATORS); + + gimple_ranger *ranger = enable_ranger (fun); + rvrp_folder folder (ranger); + folder.substitute_and_fold (); + ranger->export_global_ranges (); + if (dump_file && (dump_flags & TDF_DETAILS)) + ranger->dump (dump_file); + + + if (warn_array_bounds && warn_array_bounds_p) + { + // Set all edges as executable, except those ranger says aren't. + int non_exec_flag = ranger->non_executable_edge_flag; + basic_block bb; + FOR_ALL_BB_FN (bb, fun) + { + edge_iterator ei; + edge e; + FOR_EACH_EDGE (e, ei, bb->succs) + if (e->flags & non_exec_flag) + e->flags &= ~EDGE_EXECUTABLE; + else + e->flags |= EDGE_EXECUTABLE; + } + array_bounds_checker array_checker (fun, ranger); + array_checker.check (); + } + + disable_ranger (fun); + scev_finalize (); + loop_optimizer_finalize (); + return 0; +} + namespace { const pass_data pass_data_vrp = diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h index 3392ecc7b23..cf379de86ff 100644 --- a/gcc/tree-vrp.h +++ b/gcc/tree-vrp.h @@ -65,4 +65,6 @@ extern void maybe_set_nonzero_bits (edge, tree); extern wide_int masked_increment (const wide_int &val_in, const wide_int &mask, const wide_int &sgnbit, unsigned int prec); +extern unsigned int execute_ranger_vrp (struct function *fun, + bool warn_array_bounds_p = false); #endif /* GCC_TREE_VRP_H */ -- 2.17.2 From patchwork Thu Oct 21 13:31:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 46495 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C7B363858405 for ; Thu, 21 Oct 2021 13:34:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7B363858405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634823299; bh=VLzRLrMjhJ+3esSYBBTW9fTObyr8XhiiqULLtwz+Nu0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=RtB35/8lte9bcFkpeMWuqav8sjt+gF6JcYAyhT5GF8aDl2MfEiY9ruL3xXnafR64U XFWrxppNbLhMRaTIRj/AjcJJjKwgx3fi6o0TKfpnEIlctY+iGkkD+UJ3TTvsR9WD/s MGaBpFXXQScVwMJm1vftXM2VE+RgiVHmEVTDbzW0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id 16AFB3857C7A for ; Thu, 21 Oct 2021 13:31:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 16AFB3857C7A Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-583-w338NyxANauieNNQPK-Mow-1; Thu, 21 Oct 2021 09:31:53 -0400 X-MC-Unique: w338NyxANauieNNQPK-Mow-1 Received: by mail-qt1-f197.google.com with SMTP id d21-20020ac800d5000000b002a7ae3ec644so506439qtg.7 for ; Thu, 21 Oct 2021 06:31:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language; bh=VLzRLrMjhJ+3esSYBBTW9fTObyr8XhiiqULLtwz+Nu0=; b=IhgHmxOEEI7K8HsT5GUPCB2rSMddsbkPeavrM4fQm+7LE/joxNoLJuNcIe9vHdkiJa N/oQzhAbDV/6OJU07LVLHzNdUOgEJqgfAWHSCVkEMIyWpYEUKQUgLsjAgHiVAKpAfTJh ZF8YLpRNXlkYFNofiUFNt1v+HdY/bEeKzCgNaJPQZ92Vr2VGjaf4RH46HeC8bSc27pLH IhXiqC/8CC5zupmPVI+NJoirQDVQ7un1cT8glma5kw40QgpS9qIjB/sRvIWTuRapgDoT onuOcC+NJbyPQ21dw3aIVeAKU4K/6HJ3EWS7UzgO5wj9us6plCOzRwT+mRR3SEz3V3ro 26Tw== X-Gm-Message-State: AOAM531PTC+5G6bXZcb76ruJ/OAO5zrJ882cqlYOicn1T1yAODMi1Mph gaUc/obc/GR5e1MeL6wi4Oga5nhx89WX/HKz14caHWtNJDTgB1jnTn2xCl/tfF8S5BDnJNIOQcg Azd7YzaecoBXiJ0tZDw== X-Received: by 2002:a05:6214:4112:: with SMTP id kc18mr4648990qvb.11.1634823112440; Thu, 21 Oct 2021 06:31:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLvzwAkYNAvlXr9hrPcQiLb72L6sDFOtxfmhe5z1Zv9luU59dRnrC+cE7QspTHEF22DqBz6w== X-Received: by 2002:a05:6214:4112:: with SMTP id kc18mr4648974qvb.11.1634823112232; Thu, 21 Oct 2021 06:31:52 -0700 (PDT) Received: from ?IPv6:2607:fea8:a262:5f00::38cf? ([2607:fea8:a262:5f00::38cf]) by smtp.gmail.com with ESMTPSA id q27sm2398979qki.57.2021.10.21.06.31.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Oct 2021 06:31:51 -0700 (PDT) To: gcc-patches Subject: [COMMITTED 2/3] Add --param=vrp1-mode and --param=vrp2-mode. Message-ID: Date: Thu, 21 Oct 2021 09:31:50 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch adds 2 new --params,  vrp1-mode and vrp2-mode.  They can be used to select which version of VRP should be used for each pass. Valid options are "vrp" and "ranger": ie --param=vrp1-mode=vrp --param=vrp2-mode=ranger As VRP is the current default for both, again, there is no functional change, but it is now possible to run ranger in either of the 2 VRP passes.  The plan will be to make ranger the default for VRP2 once I've sorted out a couple of testcases. Bootstrapped on x86_64-pc-linux-gnu with no regressions. Pushed. From bd400db6d3ec167142ace352db00f84d382e33a8 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Fri, 15 Oct 2021 12:06:27 -0400 Subject: [PATCH 2/3] Add --param=vrp1-mode and --param=vrp2-mode. Add 2 new params to select between VRP and RANGER to be used for each pass. * doc/invoke.texi: (vrp1-mode, vrp2-mode): Document. * flag-types.h: (enum vrp_mode): New. * params.opt: (vrp1-mode, vrp2-mode): New. * tree-vrp.c (vrp_pass_num): New. (pass_vrp::pass_vrp): Set pass number. (pass_vrp::execute): Choose which VRP mode to execute. --- gcc/doc/invoke.texi | 6 ++++++ gcc/flag-types.h | 7 +++++++ gcc/params.opt | 17 +++++++++++++++++ gcc/tree-vrp.c | 12 ++++++++++-- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 6d1e328571a..b89f9b61f9c 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -14504,6 +14504,12 @@ Maximum number of basic blocks before EVRP uses a sparse cache. @item evrp-mode Specifies the mode Early VRP should operate in. +@item vrp1-mode +Specifies the mode VRP pass 1 should operate in. + +@item vrp2-mode +Specifies the mode VRP pass 2 should operate in. + @item evrp-switch-limit Specifies the maximum number of switch cases before EVRP ignores a switch. diff --git a/gcc/flag-types.h b/gcc/flag-types.h index ae0b216e8a3..9f104e43d40 100644 --- a/gcc/flag-types.h +++ b/gcc/flag-types.h @@ -463,6 +463,13 @@ enum evrp_mode EVRP_MODE_DEBUG = (EVRP_MODE_GORI | EVRP_MODE_CACHE) }; +/* VRP modes. */ +enum vrp_mode +{ + VRP_MODE_VRP, + VRP_MODE_RANGER +}; + /* Modes of OpenACC 'kernels' constructs handling. */ enum openacc_kernels { diff --git a/gcc/params.opt b/gcc/params.opt index 83b3db6fea6..27ef4b6578f 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -1137,4 +1137,21 @@ Controls how loop vectorizer uses partial vectors. 0 means never, 1 means only Common Joined UInteger Var(param_vect_inner_loop_cost_factor) Init(50) IntegerRange(1, 10000) Param Optimization The maximum factor which the loop vectorizer applies to the cost of statements in an inner loop relative to the loop being vectorized. +-param=vrp1-mode= +Common Joined Var(param_vrp1_mode) Enum(vrp_mode) Init(VRP_MODE_VRP) Param Optimization +--param=vrp1-mode=[vrp|ranger] Specifies the mode VRP1 should operate in. + +-param=vrp2-mode= +Common Joined Var(param_vrp2_mode) Enum(vrp_mode) Init(VRP_MODE_VRP) Param Optimization +--param=vrp2-mode=[vrp|ranger] Specifies the mode VRP2 should operate in. + +Enum +Name(vrp_mode) Type(enum vrp_mode) UnknownError(unknown vrp mode %qs) + +EnumValue +Enum(vrp_mode) String(vrp) Value(VRP_MODE_VRP) + +EnumValue +Enum(vrp_mode) String(ranger) Value(VRP_MODE_RANGER) + ; This comment is to ensure we retain the blank line above. diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index b0b217bbf86..ba7a4efc7c6 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4450,11 +4450,13 @@ const pass_data pass_data_vrp = ( TODO_cleanup_cfg | TODO_update_ssa ), /* todo_flags_finish */ }; +static int vrp_pass_num = 0; class pass_vrp : public gimple_opt_pass { public: pass_vrp (gcc::context *ctxt) - : gimple_opt_pass (pass_data_vrp, ctxt), warn_array_bounds_p (false) + : gimple_opt_pass (pass_data_vrp, ctxt), warn_array_bounds_p (false), + my_pass (++vrp_pass_num) {} /* opt_pass methods: */ @@ -4466,10 +4468,16 @@ public: } virtual bool gate (function *) { return flag_tree_vrp != 0; } virtual unsigned int execute (function *fun) - { return execute_vrp (fun, warn_array_bounds_p); } + { + if ((my_pass == 1 && param_vrp1_mode == VRP_MODE_RANGER) + || (my_pass == 2 && param_vrp2_mode == VRP_MODE_RANGER)) + return execute_ranger_vrp (fun, warn_array_bounds_p); + return execute_vrp (fun, warn_array_bounds_p); + } private: bool warn_array_bounds_p; + int my_pass; }; // class pass_vrp } // anon namespace -- 2.17.2 From patchwork Thu Oct 21 13:32:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 46496 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 349D83857C5D for ; Thu, 21 Oct 2021 13:35:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 349D83857C5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634823356; bh=yp71ZU6Haoyn4dZdMeuoQvUlyWCJZ9GAlJ15Kqc1NkU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=PqIWneGwVIGP+AntZ1sXtYAM0nNZmJyFHqoS64ga/DxnsvuggYLnWSCscPVKG6j9u 8xFfy47mqy12fJ4BbQxU+zPLqhOpWToSxeO37pke3goL1Vf334uScryKogLQu5W02P 5YtDI+C2IH7qvxfzYWFdeIjJ0h32nyI+jtZpSHfM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 06EE43858D39 for ; Thu, 21 Oct 2021 13:32:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 06EE43858D39 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-280-r7I_DgCsM26shqWN_DbBtQ-1; Thu, 21 Oct 2021 09:32:03 -0400 X-MC-Unique: r7I_DgCsM26shqWN_DbBtQ-1 Received: by mail-qk1-f197.google.com with SMTP id s20-20020a05620a0bd400b0045e893f2ed8so535918qki.11 for ; Thu, 21 Oct 2021 06:32:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language; bh=yp71ZU6Haoyn4dZdMeuoQvUlyWCJZ9GAlJ15Kqc1NkU=; b=PEwT9P586Zx2Q6iKfJNen4JJhuL/NrDDdof2rZW9sAIn0kWeWn1Vv8zK06sr0siQrd umlP2Q8Kbi780hDQnObRbrb8uJbk2XVW2wXYQYypIlr23+Hc53RLshfwCj8im3lvLFZZ a3tqpW5pT+FnSkbykzCiBzoWC3xEd6L0bsIdFDFFLfNsCWErof2zZpDl7Em/b+KSGOdJ dwd/GHV2AsKNg+/Y8LCd8FwO28ArIg4NGe2GhSvfaLTALfh1GHUXvlKr69vZOGw0hz5s BkwlbAjt0zN7jLrjBAu5MTVB/aWj4YXtdQZJ8IY7WZTa0RpYOqr/Czx84DDL2ETMjhgR kBFw== X-Gm-Message-State: AOAM530K/4TZb9P5d5ib+tzDDGvWPycJCXGFvVdck0lSoYLeU4pCiUzT /PkGxH7+doPgao0sYDIXmJ1LTl8ZRdZd3+4QvpebXbIQPT96lf8/vox4yUQStfS//i+ryZdNfZx U0MOpK34gCi32AstJnA== X-Received: by 2002:a05:620a:f07:: with SMTP id v7mr4301019qkl.143.1634823122170; Thu, 21 Oct 2021 06:32:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIF5ijVV0Wg6dlbgSBpBSqOdXeEMYrcJyj6kqvf+Nx1mpTBU3uJxF/6kzY3WpkNljtQim/TQ== X-Received: by 2002:a05:620a:f07:: with SMTP id v7mr4301001qkl.143.1634823121996; Thu, 21 Oct 2021 06:32:01 -0700 (PDT) Received: from ?IPv6:2607:fea8:a262:5f00::38cf? ([2607:fea8:a262:5f00::38cf]) by smtp.gmail.com with ESMTPSA id q14sm2438068qtl.73.2021.10.21.06.32.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Oct 2021 06:32:01 -0700 (PDT) To: gcc-patches Subject: [COMMITTED 3/3] Split --param=evrp-mode into evrp-mode and ranger-debug. Message-ID: Date: Thu, 21 Oct 2021 09:32:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Should have done this a while ago.  With ranger being utilized in other places, tying the debug output mode with the EVRP mode no longer makes sense. This patch splits the current --param=evrp-mode values into "evrp-mode" and "ranger-debug".   After this patch, valid values are: --param=evrp-mode=[legacy|ranger|legacy-first|ranger-first] default is "ranger" --param=ranger-debug=[none|trace|gori|cache|tracegori|all] default is "none" Again, this provides no real functional changes. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. From 9cb114fd5550eb02dfd6b8db5cb5b8fb72827d53 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 19 Oct 2021 14:09:51 -0400 Subject: [PATCH 3/3] Split --param=evrp-mode into evrp-mode and ranger-debug. With Ranger being used in more than EVRP, the debug output should no longer be tied up with the EVRP mode flag. * doc/invoke.texi (ranger-debug): Document. * flag-types.h (enum ranger_debug): New. (enum evrp_mode): Remove debug values. * gimple-range-cache.cc (DEBUG_RANGE_CACHE): Use new debug flag. * gimple-range-gori.cc (gori_compute::gori_compute): Ditto. * gimple-range.cc (gimple_ranger::gimple_ranger): Ditto. * gimple-ssa-evrp.c (hybrid_folder::choose_value): Ditto. (execute_early_vrp): Use evrp-mode directly. * params.opt (enum evrp_mode): Remove debug values. (ranger-debug): New. (ranger-logical-depth): Relocate to be in alphabetical order. --- gcc/doc/invoke.texi | 3 +++ gcc/flag-types.h | 24 +++++++++++------- gcc/gimple-range-cache.cc | 4 +-- gcc/gimple-range-gori.cc | 2 +- gcc/gimple-range.cc | 2 +- gcc/gimple-ssa-evrp.c | 6 ++--- gcc/params.opt | 52 +++++++++++++++++++++++---------------- 7 files changed, 56 insertions(+), 37 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index b89f9b61f9c..c66a25fcd69 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -14510,6 +14510,9 @@ Specifies the mode VRP pass 1 should operate in. @item vrp2-mode Specifies the mode VRP pass 2 should operate in. +@item ranger-debug +Specifies the type of debug output to be issued for ranges. + @item evrp-switch-limit Specifies the maximum number of switch cases before EVRP ignores a switch. diff --git a/gcc/flag-types.h b/gcc/flag-types.h index 9f104e43d40..a5a637160d7 100644 --- a/gcc/flag-types.h +++ b/gcc/flag-types.h @@ -449,18 +449,24 @@ enum parloops_schedule_type PARLOOPS_SCHEDULE_RUNTIME }; +/* Ranger debug mode. */ +enum ranger_debug +{ + RANGER_DEBUG_NONE = 0, + RANGER_DEBUG_TRACE = 1, + RANGER_DEBUG_CACHE = (2 | RANGER_DEBUG_TRACE), + RANGER_DEBUG_GORI = 4, + RANGER_DEBUG_TRACE_GORI = (RANGER_DEBUG_TRACE | RANGER_DEBUG_GORI), + RANGER_DEBUG_ALL = (RANGER_DEBUG_GORI | RANGER_DEBUG_CACHE) +}; + /* EVRP mode. */ enum evrp_mode { - EVRP_MODE_RVRP_ONLY = 0, - EVRP_MODE_EVRP_ONLY = 1, - EVRP_MODE_EVRP_FIRST = 2, - EVRP_MODE_RVRP_FIRST = 3, - EVRP_MODE_TRACE = 4, - EVRP_MODE_CACHE = (8 | EVRP_MODE_TRACE), - EVRP_MODE_GORI = 16, - EVRP_MODE_TRACE_GORI = (EVRP_MODE_TRACE | EVRP_MODE_GORI), - EVRP_MODE_DEBUG = (EVRP_MODE_GORI | EVRP_MODE_CACHE) + EVRP_MODE_RVRP_ONLY, + EVRP_MODE_EVRP_ONLY, + EVRP_MODE_EVRP_FIRST, + EVRP_MODE_RVRP_FIRST }; /* VRP modes. */ diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 9cbc63d8a40..05010cf15bc 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -30,8 +30,8 @@ along with GCC; see the file COPYING3. If not see #include "gimple-range.h" #include "tree-cfg.h" -#define DEBUG_RANGE_CACHE (dump_file && (param_evrp_mode & EVRP_MODE_CACHE) \ - == EVRP_MODE_CACHE) +#define DEBUG_RANGE_CACHE (dump_file \ + && (param_ranger_debug & RANGER_DEBUG_CACHE)) // During contructor, allocate the vector of ssa_names. diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index 6946fa65dda..4e45c593871 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -644,7 +644,7 @@ gori_compute::gori_compute (int not_executable_flag) // Create a boolean_type true and false range. m_bool_zero = int_range<2> (boolean_false_node, boolean_false_node); m_bool_one = int_range<2> (boolean_true_node, boolean_true_node); - if (dump_file && (param_evrp_mode & EVRP_MODE_GORI)) + if (dump_file && (param_ranger_debug & RANGER_DEBUG_GORI)) tracer.enable_trace (); } diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 93d6da66ccb..69cde911c49 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -42,7 +42,7 @@ gimple_ranger::gimple_ranger () : { // If the cache has a relation oracle, use it. m_oracle = m_cache.oracle (); - if (dump_file && (param_evrp_mode & EVRP_MODE_TRACE)) + if (dump_file && (param_ranger_debug & RANGER_DEBUG_TRACE)) tracer.enable_trace (); // Ensure the not_executable flag is clear everywhere. diff --git a/gcc/gimple-ssa-evrp.c b/gcc/gimple-ssa-evrp.c index a0192e2b2aa..c3f84050c9e 100644 --- a/gcc/gimple-ssa-evrp.c +++ b/gcc/gimple-ssa-evrp.c @@ -300,7 +300,7 @@ hybrid_folder::choose_value (tree evrp_val, tree ranger_val) return evrp_val; // If values are different, return the first calculated value. - if ((param_evrp_mode & EVRP_MODE_RVRP_FIRST) == EVRP_MODE_RVRP_FIRST) + if (param_evrp_mode == EVRP_MODE_RVRP_FIRST) return ranger_val; return evrp_val; } @@ -312,7 +312,7 @@ hybrid_folder::choose_value (tree evrp_val, tree ranger_val) static unsigned int execute_early_vrp () { - if ((param_evrp_mode & EVRP_MODE_RVRP_FIRST) == EVRP_MODE_RVRP_ONLY) + if (param_evrp_mode == EVRP_MODE_RVRP_ONLY) return execute_ranger_vrp (cfun, false); /* Ideally this setup code would move into the ctor for the folder @@ -325,7 +325,7 @@ execute_early_vrp () calculate_dominance_info (CDI_DOMINATORS); // Only the last 2 bits matter for choosing the folder. - switch (param_evrp_mode & EVRP_MODE_RVRP_FIRST) + switch (param_evrp_mode) { case EVRP_MODE_EVRP_ONLY: { diff --git a/gcc/params.opt b/gcc/params.opt index 27ef4b6578f..393d52bc660 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -136,7 +136,7 @@ Maximum number of outgoing edges in a switch before EVRP will not process it. -param=evrp-mode= Common Joined Var(param_evrp_mode) Enum(evrp_mode) Init(EVRP_MODE_RVRP_ONLY) Param Optimization ---param=evrp-mode=[legacy|ranger|legacy-first|ranger-first|trace|gori|cache|tracegori|debug] Specifies the mode Early VRP should operate in. +--param=evrp-mode=[legacy|ranger|legacy-first|ranger-first] Specifies the mode Early VRP should operate in. Enum Name(evrp_mode) Type(enum evrp_mode) UnknownError(unknown evrp mode %qs) @@ -153,26 +153,6 @@ Enum(evrp_mode) String(legacy-first) Value(EVRP_MODE_EVRP_FIRST) EnumValue Enum(evrp_mode) String(ranger-first) Value(EVRP_MODE_RVRP_FIRST) -EnumValue -Enum(evrp_mode) String(trace) Value(EVRP_MODE_TRACE) - -EnumValue -Enum(evrp_mode) String(cache) Value(EVRP_MODE_CACHE) - -EnumValue -Enum(evrp_mode) String(gori) Value(EVRP_MODE_GORI) - -EnumValue -Enum(evrp_mode) String(tracegori) Value(EVRP_MODE_TRACE_GORI) - -EnumValue -Enum(evrp_mode) String(debug) Value(EVRP_MODE_DEBUG) - --param=ranger-logical-depth= -Common Joined UInteger Var(param_ranger_logical_depth) Init(6) IntegerRange(1, 999) Param Optimization -Maximum depth of logical expression evaluation ranger will look through when -evaluating outgoing edge ranges. - -param=fsm-scale-path-blocks= Common Joined UInteger Var(param_fsm_scale_path_blocks) Init(3) IntegerRange(1, 10) Param Optimization Scale factor to apply to the number of blocks in a threading path when comparing to the number of (scaled) statements. @@ -893,6 +873,36 @@ The minimum constant stride beyond which we should use prefetch hints for. Common Joined UInteger Var(param_profile_func_internal_id) IntegerRange(0, 1) Param Use internal function id in profile lookup. +-param=ranger-debug= +Common Joined Var(param_ranger_debug) Enum(ranger_debug) Init(RANGER_DEBUG_NONE) Param Optimization +--param=ranger-debug=[none|trace|gori|cache|tracegori|all] Specifies the output mode for debugging ranger. + +Enum +Name(ranger_debug) Type(enum ranger_debug) UnknownError(unknown ranger debug mode %qs) + +EnumValue +Enum(ranger_debug) String(none) Value(RANGER_DEBUG_NONE) + +EnumValue +Enum(ranger_debug) String(trace) Value(RANGER_DEBUG_TRACE) + +EnumValue +Enum(ranger_debug) String(cache) Value(RANGER_DEBUG_CACHE) + +EnumValue +Enum(ranger_debug) String(gori) Value(RANGER_DEBUG_GORI) + +EnumValue +Enum(ranger_debug) String(tracegori) Value(RANGER_DEBUG_TRACE_GORI) + +EnumValue +Enum(ranger_debug) String(all) Value(RANGER_DEBUG_ALL) + +-param=ranger-logical-depth= +Common Joined UInteger Var(param_ranger_logical_depth) Init(6) IntegerRange(1, 999) Param Optimization +Maximum depth of logical expression evaluation ranger will look through when +evaluating outgoing edge ranges. + -param=rpo-vn-max-loop-depth= Common Joined UInteger Var(param_rpo_vn_max_loop_depth) Init(7) IntegerRange(2, 65536) Param Optimization Maximum depth of a loop nest to fully value-number optimistically. -- 2.17.2