public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-3908] process transitive inferred ranges in pre_fold_stmt.
@ 2022-11-11 16:16 Andrew Macleod
  0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2022-11-11 16:16 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:dab5d73959cfc8f03cba548777adda9a798e1f0e

commit r13-3908-gdab5d73959cfc8f03cba548777adda9a798e1f0e
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Wed Nov 9 10:58:15 2022 -0500

    process transitive inferred ranges in pre_fold_stmt.
    
    The subst_and_fold engine can perform some folding activity before
    calling fold_stmt, so do this work in pre_fold_stmt instead.
    
            * tree-vrp.cc (rvrp_folder::rvrp_folder): Init m_last_bb_stmt.
            (rvrp_folder::pre_fold_bb): Set m_last_bb_stmt.
            (rvrp_folder::pre_fold_stmt): Check for transitive inferred ranges.
            (rvrp_folder::fold_stmt): Check in pre_fold_stmt instead.

Diff:
---
 gcc/tree-vrp.cc | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc
index 3393c73a7db..a474d9d11e5 100644
--- a/gcc/tree-vrp.cc
+++ b/gcc/tree-vrp.cc
@@ -4442,6 +4442,7 @@ public:
   {
     m_ranger = r;
     m_pta = new pointer_equiv_analyzer (m_ranger);
+    m_last_bb_stmt = NULL;
   }
 
   ~rvrp_folder ()
@@ -4485,6 +4486,7 @@ public:
     for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
 	 gsi_next (&gsi))
       m_ranger->register_inferred_ranges (gsi.phi ());
+    m_last_bb_stmt = last_stmt (bb);
   }
 
   void post_fold_bb (basic_block bb) override
@@ -4497,19 +4499,14 @@ public:
   void pre_fold_stmt (gimple *stmt) override
   {
     m_pta->visit_stmt (stmt);
+    // If this is the last stmt and there are inferred ranges, reparse the
+    // block for transitive inferred ranges that occur earlier in the block.
+    if (stmt == m_last_bb_stmt)
+      m_ranger->register_transitive_inferred_ranges (gimple_bb (stmt));
   }
 
   bool fold_stmt (gimple_stmt_iterator *gsi) override
   {
-    gimple *s = gsi_stmt (*gsi);
-    // If this is a block ending condition, and there are inferred ranges,
-    // reparse the block to see if there are any transitive inferred ranges.
-    if (is_a<gcond *> (s))
-      {
-	basic_block bb = gimple_bb (s);
-	if (bb && s == gimple_outgoing_range_stmt_p (bb))
-	  m_ranger->register_transitive_inferred_ranges (bb);
-      }
     bool ret = m_simplifier.simplify (gsi);
     if (!ret)
       ret = m_ranger->fold_stmt (gsi, follow_single_use_edges);
@@ -4523,6 +4520,7 @@ private:
   gimple_ranger *m_ranger;
   simplify_using_ranges m_simplifier;
   pointer_equiv_analyzer *m_pta;
+  gimple *m_last_bb_stmt;
 };
 
 /* Main entry point for a VRP pass using just ranger. This can be called

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-11 16:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11 16:16 [gcc r13-3908] process transitive inferred ranges in pre_fold_stmt Andrew Macleod

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).