diff mbox series

[5/8] ipa: Update value range jump functions during inlining

Message ID ri6a5eeq6l8.fsf@virgil.suse.cz
State New
Headers show
Series [1/8] ipa: Fix jump function copying | expand

Commit Message

Martin Jambor Nov. 5, 2024, 11:10 a.m. UTC
Hi,

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.

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-01  Martin Jambor  <mjambor@suse.cz>

	* 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.
---
 gcc/ipa-cp.cc   |  4 ++--
 gcc/ipa-cp.h    | 13 +++++++++++++
 gcc/ipa-prop.cc | 18 ++++++++++++++++++
 3 files changed, 33 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index fa4f0feeb8d..92dd2af19e0 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -1644,7 +1644,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,
@@ -1670,7 +1670,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 ba2ebfede63..4f569c1ee83 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 012f8a32386..3b24bcbed15 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -3486,6 +3486,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))
 		{