From 762129fe3681760cf93833f81bf3f23a1e8e2591 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Wed, 1 Apr 2020 18:52:16 +0200 Subject: Adjust value_inside_range() for irange. Any uses of VR_ANTI_RANGE are problematic if the caller sent in an irange that has more than <1> sub-range. So all functions that receive an irange should be adjusted to NEVER use VR_ANTI_RANGE. --- gcc/value-range.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc') diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 4a4c487..c2290dc 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -869,6 +869,15 @@ irange::value_inside_range (tree val) const if (undefined_p ()) return 0; + /* For constants we can just intersect and avoid using VR_ANTI_RANGE + code further below. */ + if (constant_p ()) + { + value_range v (val, val); + v.intersect (this); + return v == value_range (val, val) ? 1 : 0; + } + cmp1 = operand_less_p (val, min ()); if (cmp1 == -2) return -2; -- cgit v1.1