From: Martin Jambor Date: Wed, 11 Dec 2024 13:55:27 +0000 (+0100) Subject: ipa: Update value range jump functions during inlining X-Git-Tag: basepoints/gcc-16~3443 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92e0e0f8177530b8c6fcafe1d61ba03b00dff6a6;p=thirdparty%2Fgcc.git ipa: Update value range jump functions during inlining When inlining (during the analysis phase) a call graph edge, we update all pass-through jump functions corresponding to edges going out of the newly inlined function to be relative to the function into which we are inlining or to expose the information originally captured for the edge that is being inlined. Similarly, we can combine the value range information in pass-through jump functions corresponding to both edges, which is what this patch adds - at least for the case when the inlined pass-through is a simple, non-arithmetic one, which is the case that we also handle for constant and aggregate jump function parts. gcc/ChangeLog: 2024-11-01 Martin Jambor * ipa-cp.h: Forward declare class ipa_vr. (ipa_vr_operation_and_type_effects) Declare. * ipa-cp.cc (ipa_vr_operation_and_type_effects): Make public. * ipa-prop.cc (update_jump_functions_after_inlining): Also update value range jump functions. --- diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index e6d707c286db..a664bc03f62a 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -1653,7 +1653,7 @@ ipa_context_from_jfunc (ipa_node_params *info, cgraph_edge *cs, int csidx, DST_TYPE on value range in SRC_VR and store it to DST_VR. Return true if the result is a range that is not VARYING nor UNDEFINED. */ -static bool +bool ipa_vr_operation_and_type_effects (vrange &dst_vr, const vrange &src_vr, enum tree_code operation, @@ -1679,7 +1679,7 @@ ipa_vr_operation_and_type_effects (vrange &dst_vr, /* Same as above, but the SRC_VR argument is an IPA_VR which must first be extracted onto a vrange. */ -static bool +bool ipa_vr_operation_and_type_effects (vrange &dst_vr, const ipa_vr &src_vr, enum tree_code operation, diff --git a/gcc/ipa-cp.h b/gcc/ipa-cp.h index ba2ebfede63f..4f569c1ee838 100644 --- a/gcc/ipa-cp.h +++ b/gcc/ipa-cp.h @@ -299,4 +299,17 @@ ipa_vr_supported_type_p (tree type) return irange::supports_p (type) || prange::supports_p (type); } +class ipa_vr; + +bool ipa_vr_operation_and_type_effects (vrange &dst_vr, + const vrange &src_vr, + enum tree_code operation, + tree dst_type, tree src_type); +bool ipa_vr_operation_and_type_effects (vrange &dst_vr, + const ipa_vr &src_vr, + enum tree_code operation, + tree dst_type, tree src_type); + + + #endif /* IPA_CP_H */ diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 9070a45f6835..3d72794e37c4 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -3471,6 +3471,24 @@ update_jump_functions_after_inlining (struct cgraph_edge *cs, gcc_unreachable (); } + if (src->m_vr && src->m_vr->known_p ()) + { + value_range svr (src->m_vr->type ()); + if (!dst->m_vr || !dst->m_vr->known_p ()) + ipa_set_jfunc_vr (dst, *src->m_vr); + else if (ipa_vr_operation_and_type_effects (svr, *src->m_vr, + NOP_EXPR, + dst->m_vr->type (), + src->m_vr->type ())) + { + value_range dvr; + dst->m_vr->get_vrange (dvr); + dvr.intersect (svr); + if (!dvr.undefined_p ()) + ipa_set_jfunc_vr (dst, dvr); + } + } + if (src->agg.items && (dst_agg_p || !src->agg.by_ref)) {