Last fall, infer range processing was adjusted to allow a query to be specified for something Jakub was working on.  During VRP folding there was an oversight, and ranger was not providing a query.   This results in contextual ranges being missed.

This patch  corrects the oversight and passes ranger's cache in as the query  in apply_inferred_ranges () which provide a read-only query of the current state.   When Jakub gets back to his patches, this should then work as expected with us picking up whatever we actually know.

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

Andrew
From f2e2d6202b1af94a22775706d9987f155f3f6760 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacl...@redhat.com>
Date: Mon, 31 Mar 2025 11:18:22 -0400
Subject: [PATCH 3/9] Use the current cache when creating inferred ranges.

Infer range processing was adjusted to allow a query to be specified,
but during VRP folding, ranger was not providing a query.  This results
in contextual ranges being missed.   Pass the cache in as the query
which provide a read-only query of the current state.

	* gimple-range-cache.cc (ranger_cache::apply_inferred_ranges): Pass
	'this' as the range-query to the inferred range constructor.
---
 gcc/gimple-range-cache.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index 818b801468a..ecf03319cd4 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1861,7 +1861,7 @@ ranger_cache::apply_inferred_ranges (gimple *s)
   bool update = true;
 
   basic_block bb = gimple_bb (s);
-  gimple_infer_range infer(s);
+  gimple_infer_range infer(s, this);
   if (infer.num () == 0)
     return;
 
-- 
2.45.0

Reply via email to