* tree-vrp.c (vrp_shift_undefined_p): Remove.
(extract_range_from_binary_expr_1: Call
wide_int_range_shift_undefined_p instead of vrp_shift_undefined_p.
* wide-int-range.h (wide_int_range_shift_undefined_p): Do not
depend on sign.
From-SVN: r264228
+2018-09-12 Aldy Hernandez <aldyh@redhat.com>
+
+ * tree-vrp.c (vrp_shift_undefined_p): Remove.
+ (extract_range_from_binary_expr_1: Call
+ wide_int_range_shift_undefined_p instead of vrp_shift_undefined_p.
+ * wide-int-range.h (wide_int_range_shift_undefined_p): Do not
+ depend on sign.
+
2018-09-12 Aldy Hernandez <aldyh@redhat.com>
* gimple-ssa-warn-alloca.c
}
}
-/* Value range wrapper for wide_int_range_shift_undefined_p. */
-
-static inline bool
-vrp_shift_undefined_p (const value_range &shifter, unsigned prec)
-{
- tree type = TREE_TYPE (shifter.min);
- return wide_int_range_shift_undefined_p (TYPE_SIGN (type), prec,
- wi::to_wide (shifter.min),
- wi::to_wide (shifter.max));
-}
-
/* Value range wrapper for wide_int_range_multiplicative_op:
*VR = *VR0 .CODE. *VR1. */
|| code == LSHIFT_EXPR)
{
if (range_int_cst_p (&vr1)
- && !vrp_shift_undefined_p (vr1, prec))
+ && !wide_int_range_shift_undefined_p (prec,
+ wi::to_wide (vr1.min),
+ wi::to_wide (vr1.max)))
{
if (code == RSHIFT_EXPR)
{
/* Return TRUE if shifting by range [MIN, MAX] is undefined behavior. */
inline bool
-wide_int_range_shift_undefined_p (signop sign, unsigned prec,
+wide_int_range_shift_undefined_p (unsigned prec,
const wide_int &min, const wide_int &max)
{
/* ?? Note: The original comment said this only applied to
behavior from the shift operation. We cannot even trust
SHIFT_COUNT_TRUNCATED at this stage, because that applies to rtl
shifts, and the operation at the tree level may be widened. */
- return wi::lt_p (min, 0, sign) || wi::ge_p (max, prec, sign);
+ return wi::sign_mask (min) || wi::ge_p (max, prec, UNSIGNED);
}
/* Calculate MIN/MAX_EXPR of two ranges and store the result in [MIN, MAX]. */