* [PUSHED] VARYING ranges of different sizes should not be equal.
@ 2021-05-24 19:41 Aldy Hernandez
0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2021-05-24 19:41 UTC (permalink / raw)
To: GCC patches, Andrew MacLeod
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.
Tested on x86-64 Linux.
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.
---
gcc/value-range.cc | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 865344fcc3e..8d7b46c0239 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
--
2.31.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-24 19:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24 19:41 [PUSHED] VARYING ranges of different sizes should not be equal Aldy Hernandez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).