On 11/4/26 3:12 AM, Richard Biener wrote: > On Tue, Nov 3, 2026 at 7:36 PM Andrew MacLeod <[email protected]> wrote: >> >> There is code in ipa-prop which checks for a pointer range, and then looks >> to see if there is points to info, eiother invariant to or away,. If ti si >> there, it clears it in one case and proceeds, and bails in the other. >> This provides a helper class which simply clears the fields if it is present >> and fails the is_gimple_ip_invariant test. This simplifies the client >> code, and in the latter case still allows the range itself to be propagated >> rather than bailing. >> >> Bootstraps on x86_64-pc-linux-gnu with no regressions. OK? >> >> Andrew >> >> >> Rather than looking for and clearing points to information that is >> gimple_ip_invariant, introduce a routine and call it. >> >> * ipa-prop.cc (ipa_set_jfunc_vr): Call enw routine. >> (ipa_record_return_value_range_1): Likewise. >> * tree-ssanames.cc (clear_function_local_points_to): New. >> * tree-ssanames.h (clear_function_local_points_to)): New prototype. >> --- >> gcc/ipa-prop.cc | 30 ++++++++++-------------------- >> gcc/tree-ssanames.cc | 22 ++++++++++++++++++++++ >> gcc/tree-ssanames.h | 1 + >> 3 files changed, 33 insertions(+), 20 deletions(-) >> >> diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc >> index eb220b92eab..4df4cdfbcec 100644 >> --- a/gcc/ipa-prop.cc >> +++ b/gcc/ipa-prop.cc >> @@ -2402,11 +2402,8 @@ ipa_set_jfunc_vr (ipa_jump_func *jf, const vrange >> &tmp) >> the bitmask remain valid. */ >> if (is_a <prange> (tmp)) >> { >> - const prange &pr = as_a <prange> (tmp); >> - tree t = pr.pt_invariant (); >> - if (!t) >> - t = pr.pt_invariant_away (); >> - if (t && !is_gimple_ip_invariant (t)) >> + prange p = as_a <prange> (tmp); >> + if (clear_function_local_points_to (p)) >> { >> if (dump_file && (dump_flags & TDF_DETAILS)) >> { >> @@ -2414,13 +2411,11 @@ ipa_set_jfunc_vr (ipa_jump_func *jf, const vrange >> &tmp) >> tmp.dump (dump_file); >> fprintf (dump_file, "\n"); >> } >> - prange stripped = pr; >> - stripped.set_pt_unknown (); >> - jf->m_vr = ipa_get_value_range (stripped); >> - return; >> } >> + jf->m_vr = ipa_get_value_range (p); >> } >> - jf->m_vr = ipa_get_value_range (tmp); >> + else >> + jf->m_vr = ipa_get_value_range (tmp); >> } >> >> static void >> @@ -6037,21 +6032,16 @@ ipa_record_return_value_range_1 (cgraph_node *n, >> value_range val) >> // Remove local invariant from return values. >> if (is_a<prange> (val)) >> { >> - const prange &pr = as_a <prange> (val); >> - tree t = pr.pt_invariant (); >> - if (!t) >> - t = pr.pt_invariant_away (); >> - if (t && !is_gimple_ip_invariant (t)) >> - { >> + if (clear_function_local_points_to (val)) >> + { >> if (dump_file && (dump_flags & TDF_DETAILS)) >> { >> - fprintf (dump_file, "Could not record return range of %s:", >> n->dump_name ()); >> + fprintf (dump_file, "Dropping non ipa invariant points-to >> from"); >> + fprintf (dump_file, " return range of %s:", n->dump_name ()); >> val.dump (dump_file); >> fprintf (dump_file, "\n"); >> - fprintf (dump_file, "Because uses non ipa invariant\n"); >> } >> - return; >> - } >> + } >> } >> if (!ipa_return_value_sum) >> { >> diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc >> index 18678e41fca..b24cdc878ca 100644 >> --- a/gcc/tree-ssanames.cc >> +++ b/gcc/tree-ssanames.cc >> @@ -956,6 +956,28 @@ duplicate_ssa_name_ptr_info (tree dest, tree src) >> duplicate_ssa_name_ptr_info (dest, pt); >> } >> >> + >> +/* Remove any function-local points-to references from R, preserving its >> + bounds and bitmask and any invariant target. Return TRUE if any points >> to >> + info was removed. */ > > So this doesn't do anything to pt_solution? IMO the function is misnamed > then? Why is it not a member function of prange or somewhere in > value-range.cc? > NO, but it does to pranges points-to information, which is all function local.
THis is when prange points-to or points-away from an object in the current function... So unfortunately there is a slight clash in terminology at the moment :-P I was going to look into the possibility of moving the pt_solution object directly into a prange_storage object, and then maybe combine them somehow, but then we're introducing flow sensitive stuff back into it, so that doesnt make sense. I'll hold off on this patch and the following inlining patch until we figuire out a naming change so its less confusing. Andrew
