aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2018-10-17 12:31:58 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2018-10-17 12:31:58 +0000
commitfa6b20f32c28aa34efc3c0ab609303d8371b57dd (patch)
treee8781870b88d8bbf90c3f28bcc688cbb94665b04 /gcc
parentcd1e244a1ced255fb0a5651bdab443fa254d9472 (diff)
downloadgcc-fa6b20f32c28aa34efc3c0ab609303d8371b57dd.zip
gcc-fa6b20f32c28aa34efc3c0ab609303d8371b57dd.tar.gz
gcc-fa6b20f32c28aa34efc3c0ab609303d8371b57dd.tar.bz2
wide-int-range.h (wide_int_range_shift_undefined_p): Adjust to use sign as argument.
* wide-int-range.h (wide_int_range_shift_undefined_p): Adjust to use sign as argument. * tree-vrp.c (extract_range_from_binary_expr_1): Pass sign to wide_int_range_shift_undefined_p. From-SVN: r265237
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tree-vrp.c3
-rw-r--r--gcc/wide-int-range.h7
3 files changed, 13 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b398d1b..4768b96 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-10-17 Aldy Hernandez <aldyh@redhat.com>
+
+ * wide-int-range.h (wide_int_range_shift_undefined_p): Adjust to
+ use sign as argument.
+ * tree-vrp.c (extract_range_from_binary_expr_1): Pass sign to
+ wide_int_range_shift_undefined_p.
+
2018-10-16 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* config/aarch64/aarch64.md (despeculate_copy<ALLI_TI:mode>):
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index cbc2ea2..c519613 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -1521,7 +1521,8 @@ extract_range_from_binary_expr_1 (value_range *vr,
|| code == LSHIFT_EXPR)
{
if (range_int_cst_p (&vr1)
- && !wide_int_range_shift_undefined_p (prec,
+ && !wide_int_range_shift_undefined_p (TYPE_SIGN (TREE_TYPE (vr1.min)),
+ prec,
wi::to_wide (vr1.min),
wi::to_wide (vr1.max)))
{
diff --git a/gcc/wide-int-range.h b/gcc/wide-int-range.h
index e9ee418..0b2dd22 100644
--- a/gcc/wide-int-range.h
+++ b/gcc/wide-int-range.h
@@ -128,10 +128,11 @@ extern bool wide_int_range_div (wide_int &wmin, wide_int &wmax,
bool &extra_range_p,
wide_int &extra_min, wide_int &extra_max);
-/* Return TRUE if shifting by range [MIN, MAX] is undefined behavior. */
+/* Return TRUE if shifting by range [MIN, MAX] is undefined behavior,
+ interpreting MIN and MAX according to SIGN. */
inline bool
-wide_int_range_shift_undefined_p (unsigned prec,
+wide_int_range_shift_undefined_p (signop sign, unsigned prec,
const wide_int &min, const wide_int &max)
{
/* ?? Note: The original comment said this only applied to
@@ -142,7 +143,7 @@ wide_int_range_shift_undefined_p (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::sign_mask (min) || wi::ge_p (max, prec, UNSIGNED);
+ return wi::lt_p (min, 0, sign) || wi::ge_p (max, prec, sign);
}
/* Calculate MIN/MAX_EXPR of two ranges and store the result in [MIN, MAX]. */