]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/112843 - update_stmt doing wrong things
authorRichard Biener <rguenther@suse.de>
Tue, 5 Dec 2023 08:21:35 +0000 (09:21 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 6 Dec 2023 07:24:35 +0000 (08:24 +0100)
The following removes range_query::update_stmt and its single
invocation from update_stmt_operands.  That function is not
supposed to look beyond the raw stmt contents of the passed
stmt since there's no guarantee about the rest of the IL.

PR tree-optimization/112843
* tree-ssa-operands.cc (update_stmt_operands): Do not call
update_stmt from ranger.
* value-query.h (range_query::update_stmt): Remove.
* gimple-range.h (gimple_ranger::update_stmt): Likewise.
* gimple-range.cc (gimple_ranger::update_stmt): Likewise.

gcc/gimple-range.cc
gcc/gimple-range.h
gcc/tree-ssa-operands.cc
gcc/value-query.h

index 5e9bb397a20b8c7bc7900d371a05037d4f4c7e3d..84d2c7516e68ca73f2b6cbdf05afc74a3d4b4530 100644 (file)
@@ -544,40 +544,6 @@ gimple_ranger::register_transitive_inferred_ranges (basic_block bb)
     }
 }
 
-// When a statement S has changed since the result was cached, re-evaluate
-// and update the global cache.
-
-void
-gimple_ranger::update_stmt (gimple *s)
-{
-  tree lhs = gimple_get_lhs (s);
-  if (!lhs || !gimple_range_ssa_p (lhs))
-    return;
-  Value_Range r (TREE_TYPE (lhs));
-  // Only update if it already had a value.
-  if (m_cache.get_global_range (r, lhs))
-    {
-      // Re-calculate a new value using just cache values.
-      Value_Range tmp (TREE_TYPE (lhs));
-      fold_using_range f;
-      fur_stmt src (s, &m_cache);
-      f.fold_stmt (tmp, s, src, lhs);
-
-      // Combine the new value with the old value to check for a change.
-      if (r.intersect (tmp))
-       {
-         if (dump_file && (dump_flags & TDF_DETAILS))
-           {
-             print_generic_expr (dump_file, lhs, TDF_SLIM);
-             fprintf (dump_file, " : global value re-evaluated to ");
-             r.dump (dump_file);
-             fputc ('\n', dump_file);
-           }
-         m_cache.set_global_range (lhs, r);
-       }
-    }
-}
-
 // This routine will export whatever global ranges are known to GCC
 // SSA_RANGE_NAME_INFO and SSA_NAME_PTR_INFO fields.
 
index 5807a2b80e54e929a1ba44c624f8da5ceee4c2e7..6b0835c4ca11f285d1fc106bed9becc39018a7ab 100644 (file)
@@ -52,7 +52,6 @@ public:
   virtual bool range_of_stmt (vrange &r, gimple *, tree name = NULL) override;
   virtual bool range_of_expr (vrange &r, tree name, gimple * = NULL) override;
   virtual bool range_on_edge (vrange &r, edge e, tree name) override;
-  virtual void update_stmt (gimple *) override;
   void range_on_entry (vrange &r, basic_block bb, tree name);
   void range_on_exit (vrange &r, basic_block bb, tree name);
   void export_global_ranges ();
index 57e393ae1644810ed0a6f363aec369e415b47ceb..b0516a00d64758efc987c90b5dd765a2f804098a 100644 (file)
@@ -30,7 +30,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "stmt.h"
 #include "print-tree.h"
 #include "dumpfile.h"
-#include "value-query.h"
 
 
 /* This file contains the code required to manage the operands cache of the
@@ -1146,8 +1145,6 @@ update_stmt_operands (struct function *fn, gimple *stmt)
   gcc_assert (gimple_modified_p (stmt));
   operands_scanner (fn, stmt).build_ssa_operands ();
   gimple_set_modified (stmt, false);
-  // Inform the active range query an update has happened.
-  get_range_query (fn)->update_stmt (stmt);
 
   timevar_pop (TV_TREE_OPS);
 }
index 429446b32eb4ebfaacf2787538fac5da0296e5bb..0a6f18b03f604bd4166baf8216933878a3b7ed14 100644 (file)
@@ -71,9 +71,6 @@ public:
   virtual bool range_on_edge (vrange &r, edge, tree expr);
   virtual bool range_of_stmt (vrange &r, gimple *, tree name = NULL);
 
-  // When the IL in a stmt is changed, call this for better results.
-  virtual void update_stmt (gimple *) { }
-
   // Query if there is any relation between SSA1 and SSA2.
   relation_kind query_relation (gimple *s, tree ssa1, tree ssa2,
                                bool get_range = true);