@@ -1756,7 +1756,7 @@ ipa_vr_intersect_with_arith_jfunc (vrange &vr,
if (!handler)
return;
value_range op_vr (TREE_TYPE (operand));
- ipa_range_set_and_normalize (op_vr, operand);
+ ipa_get_range_from_ip_invariant (op_vr, operand);
tree operation_type;
if (TREE_CODE_CLASS (operation) == tcc_comparison)
@@ -519,7 +519,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node,
value_range op0 (TREE_TYPE (op->val[0]));
range_op_handler handler (op->code);
- ipa_range_set_and_normalize (op0, op->val[0]);
+ ipa_get_range_from_ip_invariant (op0, op->val[0]);
if (!handler
|| !res.supports_type_p (op->type)
@@ -538,7 +538,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node,
value_range val_vr (TREE_TYPE (c->val));
range_op_handler handler (c->code);
- ipa_range_set_and_normalize (val_vr, c->val);
+ ipa_get_range_from_ip_invariant (val_vr, c->val);
if (!handler
|| !val_vr.supports_type_p (TREE_TYPE (c->val))
@@ -2312,6 +2312,23 @@ ipa_set_jfunc_vr (ipa_jump_func *jf, const ipa_vr &vr)
ipa_set_jfunc_vr (jf, tmp);
}
+/* 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))
+ r.set_nonzero (TREE_TYPE (val));
+ else
+ r.set_varying (TREE_TYPE (val));
+ }
+ else
+ r.set (val, val);
+}
/* If T is an SSA_NAME that is a result of a simple type conversion statement,
return the operand of that conversion, otherwise treturn T. */
@@ -1257,7 +1257,7 @@ tree ipcp_get_aggregate_const (struct function *func, tree parm, bool by_ref,
HOST_WIDE_INT bit_size);
bool unadjusted_ptr_and_unit_offset (tree op, tree *ret,
poly_int64 *offset_ret);
-
+void ipa_get_range_from_ip_invariant (vrange &r, tree val);
void ipa_prop_cc_finalize (void);
/* From tree-sra.cc: */
@@ -1266,19 +1266,6 @@ tree build_ref_for_offset (location_t, tree, poly_int64, bool, tree,
/* In ipa-cp.cc */
void ipa_cp_cc_finalize (void);
-
-/* Set R to the range of [VAL, VAL] while normalizing addresses to
- non-zero. */
-
-inline void
-ipa_range_set_and_normalize (vrange &r, tree val)
-{
- if (TREE_CODE (val) == ADDR_EXPR)
- r.set_nonzero (TREE_TYPE (val));
- else
- r.set (val, val);
-}
-
bool ipa_return_value_range (value_range &range, tree decl);
void ipa_record_return_value_range (value_range val);
bool ipa_jump_functions_equivalent_p (ipa_jump_func *jf1, ipa_jump_func *jf2);