aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2024-03-19 17:55:58 +0100
committerAldy Hernandez <aldyh@redhat.com>2024-05-07 12:17:50 +0200
commit24853cd854eb9b8a5c7b9706ad0908221bf964ce (patch)
tree5efdaa06ab5e3d2c868d2a50fbd626cab7cba6c3 /gcc
parentf68e90a0fe88c50ad6f4b15ba9e9503c710d3444 (diff)
downloadgcc-24853cd854eb9b8a5c7b9706ad0908221bf964ce.zip
gcc-24853cd854eb9b8a5c7b9706ad0908221bf964ce.tar.gz
gcc-24853cd854eb9b8a5c7b9706ad0908221bf964ce.tar.bz2
Minor range type fixes for IPA in preparation for prange.
The polymorphic Value_Range object takes a tree type at construction so it can determine what type of range to use (currently irange or frange). It seems a few of the types are slightly off. This isn't a problem now, because IPA only cares about integers and pointers, which can both live in an irange. However, with prange coming about, we need to get the type right, because you can't store an integer in a pointer range or vice versa. Also, in preparation for prange, the irange::supports_p() idiom will become: irange::supports_p () || prange::supports_p() To avoid changing all these places, I've added an inline function we can later change and change everything at once. Finally, there's a Value_Range::supports_type_p() && irange::supports_p() in the code. The latter is a subset of the former, so there's no need to check both. gcc/ChangeLog: * ipa-cp.cc (ipa_vr_operation_and_type_effects): Use ipa_supports_p. (ipa_value_range_from_jfunc): Change Value_Range type. (propagate_vr_across_jump_function): Same. * ipa-cp.h (ipa_supports_p): New. * ipa-fnsummary.cc (evaluate_conditions_for_known_args): Change Value_Range type. * ipa-prop.cc (ipa_compute_jump_functions_for_edge): Use ipa_supports_p. (ipcp_get_parm_bits): Same.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ipa-cp.cc14
-rw-r--r--gcc/ipa-cp.h8
-rw-r--r--gcc/ipa-fnsummary.cc2
-rw-r--r--gcc/ipa-prop.cc8
4 files changed, 19 insertions, 13 deletions
diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index a688dce..5781f50 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -1649,7 +1649,7 @@ ipa_vr_operation_and_type_effects (vrange &dst_vr,
enum tree_code operation,
tree dst_type, tree src_type)
{
- if (!irange::supports_p (dst_type) || !irange::supports_p (src_type))
+ if (!ipa_supports_p (dst_type) || !ipa_supports_p (src_type))
return false;
range_op_handler handler (operation);
@@ -1720,7 +1720,7 @@ ipa_value_range_from_jfunc (vrange &vr,
if (TREE_CODE_CLASS (operation) == tcc_unary)
{
- Value_Range res (vr_type);
+ Value_Range res (parm_type);
if (ipa_vr_operation_and_type_effects (res,
srcvr,
@@ -1733,7 +1733,7 @@ ipa_value_range_from_jfunc (vrange &vr,
Value_Range op_res (vr_type);
Value_Range res (vr_type);
tree op = ipa_get_jf_pass_through_operand (jfunc);
- Value_Range op_vr (vr_type);
+ Value_Range op_vr (TREE_TYPE (op));
range_op_handler handler (operation);
ipa_range_set_and_normalize (op_vr, op);
@@ -2527,7 +2527,7 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc,
if (src_lats->m_value_range.bottom_p ())
return dest_lat->set_to_bottom ();
- Value_Range vr (operand_type);
+ Value_Range vr (param_type);
if (TREE_CODE_CLASS (operation) == tcc_unary)
ipa_vr_operation_and_type_effects (vr,
src_lats->m_value_range.m_vr,
@@ -2540,16 +2540,16 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc,
{
tree op = ipa_get_jf_pass_through_operand (jfunc);
Value_Range op_vr (TREE_TYPE (op));
- Value_Range op_res (operand_type);
+ Value_Range op_res (param_type);
range_op_handler handler (operation);
ipa_range_set_and_normalize (op_vr, op);
if (!handler
- || !op_res.supports_type_p (operand_type)
+ || !ipa_supports_p (operand_type)
|| !handler.fold_range (op_res, operand_type,
src_lats->m_value_range.m_vr, op_vr))
- op_res.set_varying (operand_type);
+ op_res.set_varying (param_type);
ipa_vr_operation_and_type_effects (vr,
op_res,
diff --git a/gcc/ipa-cp.h b/gcc/ipa-cp.h
index 7ff74fb..abeaaa4 100644
--- a/gcc/ipa-cp.h
+++ b/gcc/ipa-cp.h
@@ -291,4 +291,12 @@ public:
bool values_equal_for_ipcp_p (tree x, tree y);
+/* Return TRUE if IPA supports ranges of TYPE. */
+
+static inline bool
+ipa_supports_p (tree type)
+{
+ return irange::supports_p (type);
+}
+
#endif /* IPA_CP_H */
diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc
index 668a01e..07a853f 100644
--- a/gcc/ipa-fnsummary.cc
+++ b/gcc/ipa-fnsummary.cc
@@ -515,7 +515,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node,
}
else if (!op->val[1])
{
- Value_Range op0 (op->type);
+ Value_Range op0 (TREE_TYPE (op->val[0]));
range_op_handler handler (op->code);
ipa_range_set_and_normalize (op0, op->val[0]);
diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index b57f975..2d5c512 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -2392,10 +2392,8 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
else
{
if (param_type
- && Value_Range::supports_type_p (TREE_TYPE (arg))
- && Value_Range::supports_type_p (param_type)
- && irange::supports_p (TREE_TYPE (arg))
- && irange::supports_p (param_type)
+ && ipa_supports_p (TREE_TYPE (arg))
+ && ipa_supports_p (param_type)
&& get_range_query (cfun)->range_of_expr (vr, arg, cs->call_stmt)
&& !vr.undefined_p ())
{
@@ -5763,7 +5761,7 @@ ipcp_get_parm_bits (tree parm, tree *value, widest_int *mask)
ipcp_transformation *ts = ipcp_get_transformation_summary (cnode);
if (!ts
|| vec_safe_length (ts->m_vr) == 0
- || !irange::supports_p (TREE_TYPE (parm)))
+ || !ipa_supports_p (TREE_TYPE (parm)))
return false;
int i = ts->get_param_index (current_function_decl, parm);