]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa: Update value range jump functions during inlining
authorMartin Jambor <mjambor@suse.cz>
Wed, 11 Dec 2024 13:55:27 +0000 (14:55 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Wed, 11 Dec 2024 13:56:20 +0000 (14:56 +0100)
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  <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
gcc/ipa-cp.h
gcc/ipa-prop.cc

index e6d707c286db22c4f25639ea5c02300b516da616..a664bc03f62a6f884609a932be7bf020c97ccdfb 100644 (file)
@@ -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,
index ba2ebfede63f5bc4e9b102bf4061b2e171a29cf5..4f569c1ee838544964113e08a874fd59f6b2caab 100644 (file)
@@ -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 */
index 9070a45f683538a6e92a158da8eec213a50b0acb..3d72794e37c456e58c07cc7bd4ab81980eba2494 100644 (file)
@@ -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))
                {