From: Andrew MacLeod Date: Tue, 3 Oct 2023 16:32:10 +0000 (-0400) Subject: Don't use range_info_get_range for pointers. X-Git-Tag: basepoints/gcc-15~5753 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8808c37d29110872fa51b98e71aef9e160b4692;p=thirdparty%2Fgcc.git Don't use range_info_get_range for pointers. Pointers only track null and nonnull, so we need to handle them specially. * tree-ssanames.cc (set_range_info): Use get_ptr_info for pointers rather than range_info_get_range. --- diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc index 1eae411ac1c0..0a32444fbdf9 100644 --- a/gcc/tree-ssanames.cc +++ b/gcc/tree-ssanames.cc @@ -420,15 +420,11 @@ set_range_info (tree name, const vrange &r) // Pick up the current range, or VARYING if none. tree type = TREE_TYPE (name); - Value_Range tmp (type); - if (range_info_p (name)) - range_info_get_range (name, tmp); - else - tmp.set_varying (type); - if (POINTER_TYPE_P (type)) { - if (r.nonzero_p () && !tmp.nonzero_p ()) + struct ptr_info_def *pi = get_ptr_info (name); + // If R is nonnull and pi is not, set nonnull. + if (r.nonzero_p () && (!pi || pi->pt.null)) { set_ptr_nonnull (name); return true; @@ -436,6 +432,11 @@ set_range_info (tree name, const vrange &r) return false; } + Value_Range tmp (type); + if (range_info_p (name)) + range_info_get_range (name, tmp); + else + tmp.set_varying (type); // If the result doesn't change, or is undefined, return false. if (!tmp.intersect (r) || tmp.undefined_p ()) return false;