{
value_range vr;
ptr_qry->rvals->range_of_expr (vr, si->nonzero_chars, si->stmt);
- if (range_int_cst_p (&vr))
+ if (vr.undefined_p () || vr.varying_p ())
+ pdata->minlen = build_zero_cst (size_type_node);
+ else
{
- pdata->minlen = vr.min ();
- pdata->maxlen = vr.max ();
+ tree type = vr.type ();
+ pdata->minlen = wide_int_to_tree (type, vr.lower_bound ());
+ pdata->maxlen = wide_int_to_tree (type, vr.upper_bound ());
}
- else
- pdata->minlen = build_zero_cst (size_type_node);
}
else
pdata->minlen = build_zero_cst (size_type_node);
{
value_range vr;
ptr_qry->rvals->range_of_expr (vr, si->nonzero_chars, stmt);
- if (range_int_cst_p (&vr))
+ if (vr.varying_p () || vr.undefined_p ())
+ {
+ pdata->minlen = build_zero_cst (size_type_node);
+ pdata->maxlen = build_all_ones_cst (size_type_node);
+ }
+ else
{
- pdata->minlen = vr.min ();
- pdata->maxlen = vr.max ();
+ tree type = vr.type ();
+ pdata->minlen = wide_int_to_tree (type, vr.lower_bound ());
+ pdata->maxlen = wide_int_to_tree (type, vr.upper_bound ());
offset_int max = offset_int::from (vr.upper_bound (0), SIGNED);
if (tree maxbound = get_maxbound (si->ptr, stmt, max, ptr_qry))
pdata->maxbound = maxbound;
else
pdata->maxbound = pdata->maxlen;
}
- else
- {
- pdata->minlen = build_zero_cst (size_type_node);
- pdata->maxlen = build_all_ones_cst (size_type_node);
- }
}
else if (pdata->minlen && TREE_CODE (pdata->minlen) == INTEGER_CST)
{
vr1.set_varying (TREE_TYPE (op1));
tree vr0min, vr0max, vr1min, vr1max;
- get_legacy_range (vr0, vr0min, vr0max);
- get_legacy_range (vr1, vr1min, vr1max);
- if (!range_int_cst_p (&vr0)
+ value_range_kind kind0 = get_legacy_range (vr0, vr0min, vr0max);
+ value_range_kind kind1 = get_legacy_range (vr1, vr1min, vr1max);
+ if (kind0 != VR_RANGE
|| TREE_OVERFLOW (vr0min)
|| TREE_OVERFLOW (vr0max))
{
vr0min = vrp_val_min (TREE_TYPE (op0));
vr0max = vrp_val_max (TREE_TYPE (op0));
}
- if (!range_int_cst_p (&vr1)
+ if (kind1 != VR_RANGE
|| TREE_OVERFLOW (vr1min)
|| TREE_OVERFLOW (vr1max))
{
{
if (!query->range_of_expr (vr, op0, stmt))
vr.set_varying (TREE_TYPE (op0));
- if (range_int_cst_p (&vr))
+ if (!vr.varying_p () && !vr.undefined_p ())
{
- op0min = vr.min ();
- op0max = vr.max ();
+ tree type = vr.type ();
+ op0min = wide_int_to_tree (type, vr.lower_bound ());
+ op0max = wide_int_to_tree (type, vr.upper_bound ());
}
}
value_range vr1;
if (!query->range_of_expr (vr1, op1, stmt))
vr1.set_varying (TREE_TYPE (op1));
- if (range_int_cst_p (&vr1))
- op1min = vr1.min ();
+ if (!vr1.varying_p () && !vr1.undefined_p ())
+ op1min = wide_int_to_tree (vr1.type (), vr1.lower_bound ());
}
if (rhs_code == TRUNC_MOD_EXPR
&& TREE_CODE (op1min) == INTEGER_CST
static bool
vr_set_zero_nonzero_bits (const tree expr_type,
- const value_range *vr,
+ const irange *vr,
wide_int *may_be_nonzero,
wide_int *must_be_nonzero)
{
- if (range_int_cst_p (vr))
+ if (vr->varying_p () || vr->undefined_p ())
{
- wi_set_zero_nonzero_bits (expr_type,
- wi::to_wide (vr->min ()),
- wi::to_wide (vr->max ()),
- *may_be_nonzero, *must_be_nonzero);
- return true;
+ *may_be_nonzero = wi::minus_one (TYPE_PRECISION (expr_type));
+ *must_be_nonzero = wi::zero (TYPE_PRECISION (expr_type));
+ return false;
}
- *may_be_nonzero = wi::minus_one (TYPE_PRECISION (expr_type));
- *must_be_nonzero = wi::zero (TYPE_PRECISION (expr_type));
- return false;
+ wi_set_zero_nonzero_bits (expr_type, vr->lower_bound (), vr->upper_bound (),
+ *may_be_nonzero, *must_be_nonzero);
+ return true;
}
/* Optimize away redundant BIT_AND_EXPR and BIT_IOR_EXPR.
return true;
/* Now we can only handle ranges with constant bounds. */
- if (!range_int_cst_p (vr))
+ tree vrmin, vrmax;
+ value_range_kind kind = get_legacy_range (*vr, vrmin, vrmax);
+ if (kind != VR_RANGE)
return false;
/* For sign changes, the MSB of the wide_int has to be clear.
a signed wide_int, while a negative value cannot be represented
by an unsigned wide_int. */
if (src_sgn != dest_sgn
- && (wi::lts_p (wi::to_wide (vr->min ()), 0)
- || wi::lts_p (wi::to_wide (vr->max ()), 0)))
+ && (wi::lts_p (wi::to_wide (vrmin), 0)
+ || wi::lts_p (wi::to_wide (vrmax), 0)))
return false;
/* Then we can perform the conversion on both ends and compare
the result for equality. */
- tem = wi::ext (wi::to_widest (vr->min ()), dest_precision, dest_sgn);
- if (tem != wi::to_widest (vr->min ()))
+ tem = wi::ext (wi::to_widest (vrmin), dest_precision, dest_sgn);
+ if (tem != wi::to_widest (vrmin))
return false;
- tem = wi::ext (wi::to_widest (vr->max ()), dest_precision, dest_sgn);
- if (tem != wi::to_widest (vr->max ()))
+ tem = wi::ext (wi::to_widest (vrmax), dest_precision, dest_sgn);
+ if (tem != wi::to_widest (vrmax))
return false;
return true;
value_range vr;
if (query->range_of_expr (vr, innerop)
- && range_int_cst_p (&vr)
+ && !vr.varying_p ()
+ && !vr.undefined_p ()
&& range_fits_type_p (&vr,
TYPE_PRECISION (TREE_TYPE (op0)),
TYPE_SIGN (TREE_TYPE (op0)))
/* We can only handle constant ranges. */
if (!query->range_of_expr (vr, rhs1, stmt)
- || !range_int_cst_p (&vr))
+ || vr.varying_p ()
+ || vr.undefined_p ())
return false;
/* First check if we can use a signed type in place of an unsigned. */