On 11/11/22 16:56, Bernhard Reutner-Fischer wrote:
On Fri, 11 Nov 2022 11:17:17 -0500
Andrew MacLeod via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:

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
@@ -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));
    }
So of course it doesn't really matter what that stmt was, a non_debug
is as good as a debug one AFAIU, it's just a marker, as good as any SSA
version or id, i suppose. So gsi_last_nondebug_bb(bb) is not strictly
needed, fine.
It is important. It needs to be the last non-debug statement so that we can properly feed values into the final stmt of the block.. be it a conditional, switch or a return.

But since it's last_stmt(), do you have an opinion on 1) in
https://gcc.gnu.org/pipermail/gcc-help/2021-November/140908.html
by chance, as you seem to use it..

Not really.  It possible that there is a slightly more efficient way to do it, not sure how measurable it would be.  Patches always welcome :-)

Andrew

Reply via email to