> Hi, > > I believe that the current function ipa_range_set_and_normalize lacks > a check that a base of an ADDR_EXPR lacks a test whether the base > really cannot be NULL, so this patch adds it. Moreover, I never liked > the name as I do not think it makes the value of ranges any more > normal but rather just special-cases non-zero ip_invariant pointers. > Therefore, I have given it a different name and moved it to a .cc > file, our LTO bootstrap should inline (and/or split) it if necessary > anyway. > > Bootstrapped and tested on x86_64-linux, the whole patch series has > additionally passed LTO and profiled-LTO bootstrap on the same platform > and a bootstrap and testsuite on ppc64-linux. Aarch64-linux bootstrap > and testing is in progress. OK for master is that passes too? > > Thanks, > > Martin > > > gcc/ChangeLog: > > 2024-11-04 Martin Jambor <mjam...@suse.cz> > > * ipa-prop.h (ipa_get_range_from_ip_invariant): Declare. > (ipa_range_set_and_normalize): Remove. > * ipa-prop.cc (ipa_get_range_from_ip_invariant): New function. > * ipa-cp.cc (ipa_vr_intersect_with_arith_jfunc): Use > ipa_get_range_from_ip_invariant instead of > ipa_range_set_and_normalize. > * ipa-fnsummary.cc (evaluate_conditions_for_known_args): Likewise. > +/* Given VAL that conforms to is_gimple_ip_invariant, produce a VRANGE that > + represents it as a range. */ > + > +void > +ipa_get_range_from_ip_invariant (vrange &r, tree val) > +{ > + if (TREE_CODE (val) == ADDR_EXPR) > + { > + bool strict_overflow = false; > + if (tree_single_nonzero_warnv_p (val, &strict_overflow)) this function uses maybe_nonzero_address that in turn checks symtab_node::nonzero_address which uses flag_delete_null_pointer_checks to verify that we can assume that defined symbols are non-NULL. Now -fdelete-null-pointer-checks is defined in common.opt as optimization and thus is stored in TREE_OPTIMIZATION_NODE.
The patch is definitely an improvement. But it seems to me that we need to add function argument to tree_single_nonzero_warnv_p and propagate it down to symtab_node::nonzero_address so it can query in correct function context. This can be done incrementally, so the patch is OK. Honza