When examining cases, I found that an old optimization the cache was performing is no longer correct.

When a pointer range globally evolved to non-zero, the cache changed it to an invariant value and stopped tracking it.  The rationale was this saved time and effort since a nonzero pointer can no longer be refined any further.

THis is no longer true with the points to information, and was causing cases of not tracking valid expressions.

This patch re-enables tracking nonzero pointers, and is the final patch in the initial points-to set.

After all this patch set,  the VRP passes in a  build of GCC are now 1.15% *faster*  (no side table work) the threading passes have slowed down by 0.7% as there is just extra work being done. and the total over compile time change is an increase of 0.02%.. basically a wash.. bonus!

Bootstraps on x86_64-pc-linux-gnu with no new regressions. Pushed.

Andrew
From fd2921a20d9f53569323ebf0bbed876fd9e863bb Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <[email protected]>
Date: Thu, 11 Jun 2026 13:16:13 -0400
Subject: [PATCH 4/4] Pointer global ranges of nonzero are no longer invariant.

TO preserve processing, the cache did not track pointer ranges any more
once it was set to non-zero.  With prange now tracking pointers, any
conditional may provide points-to info to a nonzero range, so we
must track these values now.

	* gimple-range-cache.cc (ranger_cache::set_global_range): Nonzero
	pointer ranges are no longer invariant.
---
 gcc/gimple-range-cache.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index 6fdbd012e37..78f18a26f1b 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1171,8 +1171,11 @@ ranger_cache::set_global_range (tree name, const vrange &r, bool changed)
   // Timestamp must always be updated, or dependent calculations may
   // not include this latest value. PR 100774.
 
-  if (r.singleton_p ()
-      || (POINTER_TYPE_P (TREE_TYPE (name)) && r.nonzero_p ()))
+  // With Points_to info in prange now, it is no longer acceptable to make
+  // [1, +INF] invariant, as most points to values will have that range,
+  // and then we lose the ability to propagate points to info.
+
+  if (r.singleton_p ())
     gori_ssa ()->set_range_invariant (name);
   m_temporal->set_timestamp (name);
 }
-- 
2.45.0

Reply via email to