aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2021-05-24 19:57:29 +0200
committerAldy Hernandez <aldyh@redhat.com>2021-05-24 21:41:54 +0200
commitca8cc8273c5646482eedd567288b9f8aa3fb6492 (patch)
tree91d15ecf31b58f0b5273cf24e6e55f401b0a6913 /gcc
parent46ed811bcb4b86a81ef3d78ea8cfffc6cd043144 (diff)
downloadgcc-ca8cc8273c5646482eedd567288b9f8aa3fb6492.zip
gcc-ca8cc8273c5646482eedd567288b9f8aa3fb6492.tar.gz
gcc-ca8cc8273c5646482eedd567288b9f8aa3fb6492.tar.bz2
VARYING ranges of different sizes should not be equal.
VARYING ranges are just normal ranges that span the entire domain. Such ranges have had end-points for a few releases now, and the fact that the legacy code was still treating all VR_VARYING the same was an oversight. This patch fixes the oversight to match the multi-range behavior. gcc/ChangeLog: * value-range.cc (irange::legacy_equal_p): Check type when comparing VR_VARYING types. (range_tests_legacy): Test comparing VARYING ranges of different sizes.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/value-range.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 865344f..8d7b46c 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "ssa.h"
#include "tree-pretty-print.h"
#include "fold-const.h"
+#include "gimple-range.h"
// Here we copy between any two irange's. The ranges can be legacy or
// multi-ranges, and copying between any combination works correctly.
@@ -454,8 +455,10 @@ irange::legacy_equal_p (const irange &other) const
if (m_kind != other.m_kind)
return false;
- if (m_kind == VR_UNDEFINED || m_kind == VR_VARYING)
+ if (m_kind == VR_UNDEFINED)
return true;
+ if (m_kind == VR_VARYING)
+ return range_compatible_p (type (), other.type ());
return (vrp_operand_equal_p (tree_lower_bound (0),
other.tree_lower_bound (0))
&& vrp_operand_equal_p (tree_upper_bound (0),
@@ -2245,6 +2248,14 @@ range_tests_legacy ()
copy = legacy_range;
ASSERT_TRUE (copy.varying_p ());
}
+
+ // VARYING of different sizes should not be equal.
+ int_range_max r0 (integer_type_node);
+ int_range_max r1 (short_integer_type_node);
+ ASSERT_TRUE (r0 != r1);
+ value_range vr0 (integer_type_node);
+ int_range_max vr1 (short_integer_type_node);
+ ASSERT_TRUE (vr0 != vr1);
}
// Simulate -fstrict-enums where the domain of a type is less than the