Range_of_address was added near the start of fold_stmt(), and if it
returns a value, it immediately returns.
There are some minor followup processing bits that are performed before
fold_stmt returns that it would be useful to do, so this patch simply
moves range_of_address () into the same if sequences that the other
range_of_* () routines are in so it can also benefit from the post
processing.
Bootstrapped on x86_64-pc-linux-gnu with no regressions. Pushed.
Andrew
From fd683d8655c653d8a1b6571a6d68bec043cc5393 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <[email protected]>
Date: Wed, 17 Dec 2025 09:34:28 -0500
Subject: [PATCH 4/6] Unify range_of_address with other range_of_* routines.
When range_of_address is called, we return immeidately, missing any
potential post calculation processing.
* gimple-range-fold.cc (fold_using_range::fold_stmt): Move
range_of_address call into nested 'if' with other routines.
---
gcc/gimple-range-fold.cc | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 2a968a646d2..9119765125f 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -668,16 +668,14 @@ fold_using_range::fold_stmt (vrange &r, gimple *s, fur_source &src, tree name)
name = gimple_get_lhs (s);
// Process addresses and loads from static constructors.
- if (gimple_code (s) == GIMPLE_ASSIGN)
- {
- if (gimple_assign_rhs_code (s) == ADDR_EXPR)
- return range_of_address (as_a <prange> (r), s, src);
- if (range_from_readonly_var (r, s))
- return true;
- }
+ if (gimple_code (s) == GIMPLE_ASSIGN && range_from_readonly_var (r, s))
+ return true;
gimple_range_op_handler handler (s);
- if (handler)
+ if (gimple_code (s) == GIMPLE_ASSIGN
+ && gimple_assign_rhs_code (s) == ADDR_EXPR)
+ res = range_of_address (as_a <prange> (r), s, src);
+ else if (handler)
res = range_of_range_op (r, handler, src);
else if (is_a<gphi *>(s))
res = range_of_phi (r, as_a<gphi *> (s), src);
--
2.45.0