get_tree_range is passed a vrange object,  but it checks if value_range supports the type of the expression rather than the actual range object that is passed in.  It should check the type is supported by the object instead.

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

Andrew


From 76a487a98ed1a3047e8fee61cda4defd4f55f9af Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <[email protected]>
Date: Tue, 3 Feb 2026 11:37:57 -0500
Subject: [PATCH 1/6] get_tree_range should check the supplied range type.

get_tree_range currently checks whether value_range supports the
requested type which is incorrect.  It should check whether the supplied
vrange supports the type.

	* value-query.cc (range_query::get_tree_range): Check if return
	range R supports the expression type.
---
 gcc/value-query.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index e05f728905e..5fbe8f932a6 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -336,7 +336,7 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt,
   else
     type = TREE_TYPE (expr);
 
-  if (!value_range::supports_type_p (type))
+  if (!r.supports_type_p (type))
     {
       r.set_undefined ();
       return false;
-- 
2.45.0

Reply via email to