]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Make transitive relations an oracle option
authorAndrew MacLeod <amacleod@redhat.com>
Mon, 24 Jun 2024 14:29:06 +0000 (10:29 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Tue, 25 Jun 2024 02:14:48 +0000 (22:14 -0400)
This patch makes processing of transitive relations configurable at
dom_oracle creation.

* tree-vrp.cc (execute_fast_vrp): Do not use transitive relations.
* value-query.cc (range_query::create_relation_oracle): Add
parameter to enable transitive relations.
* value-query.h (range_query::create_relation_oracle): Likewise.
* value-relation.h (dom_oracle::dom_oracle): Likewise.
* value-relation.cc (dom_oracle::dom_oracle): Likewise.
(dom_oracle::register_transitives): Check transitive flag.

gcc/tree-vrp.cc
gcc/value-query.cc
gcc/value-query.h
gcc/value-relation.cc
gcc/value-relation.h

index 4fc33e63e7d29122a8d2a0d4311932f00a7bac7b..26979b706e5c7872e9135b96e894448f54acca52 100644 (file)
@@ -1258,7 +1258,8 @@ execute_fast_vrp (struct function *fun, bool final_p)
 
   gcc_checking_assert (!fun->x_range_query);
   fun->x_range_query = &dr;
-  get_range_query (fun)->create_relation_oracle ();
+  // Create a relation oracle without transitives.
+  get_range_query (fun)->create_relation_oracle (false);
 
   folder.substitute_and_fold ();
   if (folder.m_unreachable)
index 0a280be580bcae5246e665bd5aec789cd74aa306..cac2cb5b2bc0540c737248f18b01324e4b6f086d 100644 (file)
@@ -223,17 +223,18 @@ range_query::destroy_infer_oracle ()
 }
 
 // Create dominance based range oracle for the current query if dom info is
-// available.
+// available.  DO_TRANS_P indicates whether transitive relations should
+// be created.  This can cost more in compile time.
 
 void
-range_query::create_relation_oracle ()
+range_query::create_relation_oracle (bool do_trans_p)
 {
   gcc_checking_assert (this != &global_ranges);
   gcc_checking_assert (m_relation == &default_relation_oracle);
 
   if (!dom_info_available_p (CDI_DOMINATORS))
     return;
-  m_relation = new dom_oracle ();
+  m_relation = new dom_oracle (do_trans_p);
   gcc_checking_assert (m_relation);
 }
 
index 2572a03095d50ee7509f04771610e928751e1528..78840fd7a7832414da62e10c48766f0ea2a1ad53 100644 (file)
@@ -76,7 +76,7 @@ public:
   virtual bool range_on_exit (vrange &r, basic_block bb, tree expr);
 
   inline class relation_oracle &relation () const  { return *m_relation; }
-  void create_relation_oracle ();
+  void create_relation_oracle (bool do_trans_p = true);
   void destroy_relation_oracle ();
 
   inline class infer_range_oracle &infer_oracle () const { return *m_infer; }
index d7bc1b7255843f4b0c0684f1e09862a1ab4341eb..9293d9ed65b77442bb34182690a34336edeaeffb 100644 (file)
@@ -978,8 +978,9 @@ relation_chain_head::find_relation (const_bitmap b1, const_bitmap b2) const
 
 // Instantiate a relation oracle.
 
-dom_oracle::dom_oracle ()
+dom_oracle::dom_oracle (bool do_trans_p)
 {
+  m_do_trans_p = do_trans_p;
   m_relations.create (0);
   m_relations.safe_grow_cleared (last_basic_block_for_fn (cfun) + 1);
   m_relation_set = BITMAP_ALLOC (&m_bitmaps);
@@ -1179,6 +1180,9 @@ void
 dom_oracle::register_transitives (basic_block root_bb,
                                  const value_relation &relation)
 {
+  // Only register transitives if they are requested.
+  if (!m_do_trans_p)
+    return;
   basic_block bb;
   // Only apply transitives to certain kinds of operations.
   switch (relation.kind ())
index cf009e6aa19747e03322f42d787bfea67805990e..f168fd9ed419e7df56613c2dae6e33b54afb5877 100644 (file)
@@ -216,7 +216,7 @@ public:
 class dom_oracle : public equiv_oracle
 {
 public:
-  dom_oracle ();
+  dom_oracle (bool do_trans_p = true);
   ~dom_oracle ();
 
   void record (basic_block bb, relation_kind k, tree op1, tree op2)
@@ -229,6 +229,7 @@ public:
   void dump (FILE *f, basic_block bb) const final override;
   void dump (FILE *f) const final override;
 private:
+  bool m_do_trans_p;
   bitmap m_tmp, m_tmp2;
   bitmap m_relation_set;  // Index by ssa-name. True if a relation exists
   vec <relation_chain_head> m_relations;  // Index by BB, list of relations.