public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-2608] Replace evrp use in loop versioning with ranger.
Date: Fri, 30 Jul 2021 09:32:38 +0000 (GMT)	[thread overview]
Message-ID: <20210730093238.EF7703944437@sourceware.org> (raw)

https://gcc.gnu.org/g:6165cf6b9b4dfb6f9ef549c5a69e201eb5fa965f

commit r12-2608-g6165cf6b9b4dfb6f9ef549c5a69e201eb5fa965f
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Sat Jul 24 12:29:28 2021 +0200

    Replace evrp use in loop versioning with ranger.
    
    This patch replaces the evrp_range_analyzer in the loop versioning code
    with an on-demand ranger.
    
    Tested on x86-64 Linux.
    
    gcc/ChangeLog:
    
            * gimple-loop-versioning.cc (lv_dom_walker::lv_dom_walker): Remove
            use of m_range_analyzer.
            (loop_versioning::lv_dom_walker::before_dom_children): Same.
            (loop_versioning::lv_dom_walker::after_dom_children): Remove.
            (loop_versioning::prune_loop_conditions): Replace vr_values use
            with range_query interface.
            (pass_loop_versioning::execute): Use ranger.

Diff:
---
 gcc/gimple-loop-versioning.cc | 44 +++++++++++++++----------------------------
 1 file changed, 15 insertions(+), 29 deletions(-)

diff --git a/gcc/gimple-loop-versioning.cc b/gcc/gimple-loop-versioning.cc
index 114a22f6e5f..15e0803dc29 100644
--- a/gcc/gimple-loop-versioning.cc
+++ b/gcc/gimple-loop-versioning.cc
@@ -30,19 +30,17 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-loop.h"
 #include "ssa.h"
 #include "tree-scalar-evolution.h"
-#include "tree-chrec.h"
 #include "tree-ssa-loop-ivopts.h"
 #include "fold-const.h"
 #include "tree-ssa-propagate.h"
 #include "tree-inline.h"
 #include "domwalk.h"
-#include "alloc-pool.h"
-#include "vr-values.h"
-#include "gimple-ssa-evrp-analyze.h"
 #include "tree-vectorizer.h"
 #include "omp-general.h"
 #include "predict.h"
 #include "tree-into-ssa.h"
+#include "gimple-range.h"
+#include "tree-cfg.h"
 
 namespace {
 
@@ -261,14 +259,10 @@ private:
     lv_dom_walker (loop_versioning &);
 
     edge before_dom_children (basic_block) FINAL OVERRIDE;
-    void after_dom_children (basic_block) FINAL OVERRIDE;
 
   private:
     /* The parent pass.  */
     loop_versioning &m_lv;
-
-    /* Used to build context-dependent range information.  */
-    evrp_range_analyzer m_range_analyzer;
   };
 
   /* Used to simplify statements based on conditions that are established
@@ -308,7 +302,7 @@ private:
   bool analyze_block (basic_block);
   bool analyze_blocks ();
 
-  void prune_loop_conditions (class loop *, vr_values *);
+  void prune_loop_conditions (class loop *);
   bool prune_conditions ();
 
   void merge_loop_info (class loop *, class loop *);
@@ -500,7 +494,7 @@ loop_info::worth_versioning_p () const
 }
 
 loop_versioning::lv_dom_walker::lv_dom_walker (loop_versioning &lv)
-  : dom_walker (CDI_DOMINATORS), m_lv (lv), m_range_analyzer (false)
+  : dom_walker (CDI_DOMINATORS), m_lv (lv)
 {
 }
 
@@ -509,26 +503,12 @@ loop_versioning::lv_dom_walker::lv_dom_walker (loop_versioning &lv)
 edge
 loop_versioning::lv_dom_walker::before_dom_children (basic_block bb)
 {
-  m_range_analyzer.enter (bb);
-
   if (bb == bb->loop_father->header)
-    m_lv.prune_loop_conditions (bb->loop_father, &m_range_analyzer);
-
-  for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si);
-       gsi_next (&si))
-    m_range_analyzer.record_ranges_from_stmt (gsi_stmt (si), false);
+    m_lv.prune_loop_conditions (bb->loop_father);
 
   return NULL;
 }
 
-/* Process BB after processing the blocks it dominates.  */
-
-void
-loop_versioning::lv_dom_walker::after_dom_children (basic_block bb)
-{
-  m_range_analyzer.leave (bb);
-}
-
 /* Decide whether to replace VAL with a new value in a versioned loop.
    Return the new value if so, otherwise return null.  */
 
@@ -1482,18 +1462,21 @@ loop_versioning::analyze_blocks ()
    LOOP.  */
 
 void
-loop_versioning::prune_loop_conditions (class loop *loop, vr_values *vrs)
+loop_versioning::prune_loop_conditions (class loop *loop)
 {
   loop_info &li = get_loop_info (loop);
 
   int to_remove = -1;
   bitmap_iterator bi;
   unsigned int i;
+  int_range_max r;
   EXECUTE_IF_SET_IN_BITMAP (&li.unity_names, 0, i, bi)
     {
       tree name = ssa_name (i);
-      const value_range_equiv *vr = vrs->get_value_range (name);
-      if (vr && !vr->may_contain_p (build_one_cst (TREE_TYPE (name))))
+      gimple *stmt = first_stmt (loop->header);
+
+      if (get_range_query (cfun)->range_of_expr (r, name, stmt)
+	  && !r.contains_p (build_one_cst (TREE_TYPE (name))))
 	{
 	  if (dump_enabled_p ())
 	    dump_printf_loc (MSG_NOTE, find_loop_location (loop),
@@ -1808,7 +1791,10 @@ pass_loop_versioning::execute (function *fn)
   if (number_of_loops (fn) <= 1)
     return 0;
 
-  return loop_versioning (fn).run ();
+  enable_ranger (fn);
+  unsigned int ret = loop_versioning (fn).run ();
+  disable_ranger (fn);
+  return ret;
 }
 
 } // anon namespace


                 reply	other threads:[~2021-07-30  9:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210730093238.EF7703944437@sourceware.org \
    --to=aldyh@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).