public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] Clear invariant bit for inferred ranges.
@ 2022-06-16 18:19 Andrew MacLeod
  0 siblings, 0 replies; only message in thread
From: Andrew MacLeod @ 2022-06-16 18:19 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 691 bytes --]

When checking the results of moving the vrp1 pass to ranger, we 
triggered a failure where a non-null was not being propagated properly 
by the ranger inferring code.

When an ssa_name never occurs in an outgoing range in any block, it is 
marked as invariant and its range is not tracked in the cache.  If we 
register an inferred range such as non-zero on such a name, it needs to 
be removed from the invariant list so we can begin tracking its range.

This patch adds a flag to the set_invariant routine so it can be either 
set or cleared. When we register an inferred range, we make it no longer 
invariant.

Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed.

Andrew

[-- Attachment #2: 0002-Clear-invariant-bit-for-inferred-ranges.patch --]
[-- Type: text/x-patch, Size: 2867 bytes --]

From 6c849e2fab3f682b715a81cb4ccc792f20c00eeb Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Thu, 16 Jun 2022 12:44:33 -0400
Subject: [PATCH 2/2] Clear invariant bit for inferred ranges.

The range of an invariant SSA (no outgoing edge range anywhere) is not tracked.
If an inferred range is registered, remove the invariant flag.

	* gimple-range-cache.cc (ranger_cache::apply_inferred_ranges): If name
	was invaraint before, clear the invariant bit.
	* gimple-range-gori.cc (gori_map::set_range_invariant): Add a flag.
	* gimple-range-gori.h (gori_map::set_range_invariant): Adjust prototype.
---
 gcc/gimple-range-cache.cc |  7 ++++++-
 gcc/gimple-range-gori.cc  | 10 +++++++---
 gcc/gimple-range-gori.h   |  2 +-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index f3494363a10..5df744184c4 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1474,7 +1474,12 @@ ranger_cache::apply_inferred_ranges (gimple *s)
 	  if (!m_on_entry.get_bb_range (r, name, bb))
 	    exit_range (r, name, bb, RFD_READ_ONLY);
 	  if (r.intersect (infer.range (x)))
-	    m_on_entry.set_bb_range (name, bb, r);
+	    {
+	      m_on_entry.set_bb_range (name, bb, r);
+	      // If this range was invariant before, remove invariance.
+	      if (!m_gori.has_edge_range_p (name))
+		m_gori.set_range_invariant (name, false);
+	    }
 	}
     }
 }
diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index 0a3e54eae4e..a43e44c841e 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -499,12 +499,16 @@ gori_map::is_export_p (tree name, basic_block bb)
   return bitmap_bit_p (exports (bb), SSA_NAME_VERSION (name));
 }
 
-// Clear the m_maybe_variant bit so ranges will not be tracked for NAME.
+// Set or clear the m_maybe_variant bit to determine if ranges will be tracked
+// for NAME.  A clear bit means they will NOT be tracked.
 
 void
-gori_map::set_range_invariant (tree name)
+gori_map::set_range_invariant (tree name, bool invariant)
 {
-  bitmap_clear_bit (m_maybe_variant, SSA_NAME_VERSION (name));
+  if (invariant)
+    bitmap_clear_bit (m_maybe_variant, SSA_NAME_VERSION (name));
+  else
+    bitmap_set_bit (m_maybe_variant, SSA_NAME_VERSION (name));
 }
 
 // Return true if NAME is an import to block BB.
diff --git a/gcc/gimple-range-gori.h b/gcc/gimple-range-gori.h
index f5f691fe424..3d57ab94624 100644
--- a/gcc/gimple-range-gori.h
+++ b/gcc/gimple-range-gori.h
@@ -94,7 +94,7 @@ public:
   bool is_import_p (tree name, basic_block bb);
   bitmap exports (basic_block bb);
   bitmap imports (basic_block bb);
-  void set_range_invariant (tree name);
+  void set_range_invariant (tree name, bool invariant = true);
 
   void dump (FILE *f);
   void dump (FILE *f, basic_block bb, bool verbose = true);
-- 
2.17.2


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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-16 18:19 [COMMITTED] Clear invariant bit for inferred ranges 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).