]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
path solver: Only compute relations for imports.
authorAldy Hernandez <aldyh@redhat.com>
Wed, 3 Nov 2021 07:23:25 +0000 (08:23 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Thu, 4 Nov 2021 14:37:35 +0000 (15:37 +0100)
We are currently calculating implicit PHI relations for all PHI
arguments.  This creates unecessary work, as we only care about SSA
names in the import bitmap.  Similarly for inter-path relationals.  We
can avoid things not in the bitmap.

Tested on x86-64 and ppc64le Linux with the usual regstrap.  I also
verified that the before and after number of threads was the same
in a suite of .ii files from a bootstrap.

gcc/ChangeLog:

PR tree-optimization/102943
* gimple-range-path.cc (path_range_query::compute_phi_relations):
Only compute relations for SSA names in the import list.
(path_range_query::compute_outgoing_relations): Same.
* gimple-range-path.h (path_range_query::import_p): New.

gcc/gimple-range-path.cc
gcc/gimple-range-path.h

index d8c2a9b6a86308f0091ca92c2c6f007c118d14b9..42309886c9421ead1de3ac5b2cfc411d143926a5 100644 (file)
@@ -678,8 +678,12 @@ path_range_query::compute_phi_relations (basic_block bb, basic_block prev)
        gsi_next (&iter))
     {
       gphi *phi = iter.phi ();
+      tree result = gimple_phi_result (phi);
       unsigned nargs = gimple_phi_num_args (phi);
 
+      if (!import_p (result))
+       continue;
+
       for (size_t i = 0; i < nargs; ++i)
        if (e_in == gimple_phi_arg_edge (phi, i))
          {
@@ -701,7 +705,8 @@ path_range_query::compute_outgoing_relations (basic_block bb, basic_block next)
 
   if (stmt
       && gimple_code (stmt) == GIMPLE_COND
-      && irange::supports_type_p (TREE_TYPE (gimple_cond_lhs (stmt))))
+      && (import_p (gimple_cond_lhs (stmt))
+         || import_p (gimple_cond_rhs (stmt))))
     {
       int_range<2> r;
       gcond *cond = as_a<gcond *> (stmt);
index 541613956e119e69fd2cbd48b31a3f2ba7e63ce0..f21d07f71c444f22aa342ef5a096b818a282399a 100644 (file)
@@ -62,6 +62,7 @@ private:
   void maybe_register_phi_relation (gphi *, tree arg);
   void add_copies_to_imports ();
   bool add_to_imports (tree name, bitmap imports);
+  inline bool import_p (tree name);
 
   // Path navigation.
   void set_path (const vec<basic_block> &);
@@ -97,4 +98,13 @@ private:
   bool m_undefined_path;
 };
 
+// Return TRUE if NAME is in the import bitmap.
+
+bool
+path_range_query::import_p (tree name)
+{
+  return (TREE_CODE (name) == SSA_NAME
+         && bitmap_bit_p (m_imports, SSA_NAME_VERSION (name)));
+}
+
 #endif // GCC_TREE_SSA_THREADSOLVER_H