We can calculate wide_int_range_shift_undefined_p() without having to
pass down the sign bit of the operand. Also, vrp_shift_undefined_p is a
brain dead wrapper so I'm removing it.
OK for trunk?
commit 9aeb62d4c33b50bc007b07ec5097e8f3edd4b31b
Author: Aldy Hernandez <al...@redhat.com>
Date: Mon Sep 10 17:46:10 2018 +0200
* 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.
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 653e45b50a4..1adb919a6df 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -1018,17 +1018,6 @@ extract_range_into_wide_ints (const value_range *vr,
}
}
-/* 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. */
@@ -1565,7 +1554,9 @@ extract_range_from_binary_expr_1 (value_range *vr,
|| 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)
{
diff --git a/gcc/wide-int-range.h b/gcc/wide-int-range.h
index 589fdea4df6..e9ee418e5b2 100644
--- a/gcc/wide-int-range.h
+++ b/gcc/wide-int-range.h
@@ -131,7 +131,7 @@ extern bool wide_int_range_div (wide_int &wmin, wide_int &wmax,
/* 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
@@ -142,7 +142,7 @@ wide_int_range_shift_undefined_p (signop sign, unsigned prec,
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]. */