* [COMMITTED] Do not compare incompatible ranges in ipa-prop.
@ 2022-10-03 11:08 Aldy Hernandez
2022-10-03 11:08 ` [COMMITTED] Do not compare nonzero masks for varying Aldy Hernandez
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Aldy Hernandez @ 2022-10-03 11:08 UTC (permalink / raw)
To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez
Committed as obvious.
gcc/ChangeLog:
* ipa-prop.cc (struct ipa_vr_ggc_hash_traits): Do not compare
incompatible ranges in ipa-prop.
---
gcc/ipa-prop.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index ca5b9f31570..724c9456308 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -126,8 +126,8 @@ struct ipa_vr_ggc_hash_traits : public ggc_cache_remove <value_range *>
static bool
equal (const value_range *a, const value_range *b)
{
- return (*a == *b
- && types_compatible_p (a->type (), b->type ()));
+ return (types_compatible_p (a->type (), b->type ())
+ && *a == *b);
}
static const bool empty_zero_p = true;
static void
--
2.37.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [COMMITTED] Do not compare nonzero masks for varying.
2022-10-03 11:08 [COMMITTED] Do not compare incompatible ranges in ipa-prop Aldy Hernandez
@ 2022-10-03 11:08 ` Aldy Hernandez
2022-10-03 11:08 ` [COMMITTED] Avoid comparing ranges when sub-ranges is 0 Aldy Hernandez
2022-10-03 11:08 ` [COMMITTED] Do not pessimize range in set_nonzero_bits Aldy Hernandez
2 siblings, 0 replies; 4+ messages in thread
From: Aldy Hernandez @ 2022-10-03 11:08 UTC (permalink / raw)
To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez
There is no need to compare nonzero masks when comparing two VARYING
ranges, as they are always the same when range types are the same.
gcc/ChangeLog:
* value-range.cc (irange::legacy_equal_p): Remove nonozero mask
check when comparing VR_VARYING ranges.
---
gcc/value-range.cc | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 6154d73ccf5..ddbcdd67633 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -1233,10 +1233,7 @@ irange::legacy_equal_p (const irange &other) const
if (m_kind == VR_UNDEFINED)
return true;
if (m_kind == VR_VARYING)
- {
- return (range_compatible_p (type (), other.type ())
- && vrp_operand_equal_p (m_nonzero_mask, other.m_nonzero_mask));
- }
+ 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),
--
2.37.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [COMMITTED] Avoid comparing ranges when sub-ranges is 0.
2022-10-03 11:08 [COMMITTED] Do not compare incompatible ranges in ipa-prop Aldy Hernandez
2022-10-03 11:08 ` [COMMITTED] Do not compare nonzero masks for varying Aldy Hernandez
@ 2022-10-03 11:08 ` Aldy Hernandez
2022-10-03 11:08 ` [COMMITTED] Do not pessimize range in set_nonzero_bits Aldy Hernandez
2 siblings, 0 replies; 4+ messages in thread
From: Aldy Hernandez @ 2022-10-03 11:08 UTC (permalink / raw)
To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez
There is nothing else to compare when the number of sub-ranges is 0.
gcc/ChangeLog:
* value-range.cc (irange::operator==): Early bail on m_num_ranges
equal to 0.
---
gcc/value-range.cc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index ddbcdd67633..e1066f4946e 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -1260,6 +1260,9 @@ irange::operator== (const irange &other) const
if (m_num_ranges != other.m_num_ranges)
return false;
+ if (m_num_ranges == 0)
+ return true;
+
for (unsigned i = 0; i < m_num_ranges; ++i)
{
tree lb = tree_lower_bound (i);
--
2.37.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [COMMITTED] Do not pessimize range in set_nonzero_bits.
2022-10-03 11:08 [COMMITTED] Do not compare incompatible ranges in ipa-prop Aldy Hernandez
2022-10-03 11:08 ` [COMMITTED] Do not compare nonzero masks for varying Aldy Hernandez
2022-10-03 11:08 ` [COMMITTED] Avoid comparing ranges when sub-ranges is 0 Aldy Hernandez
@ 2022-10-03 11:08 ` Aldy Hernandez
2 siblings, 0 replies; 4+ messages in thread
From: Aldy Hernandez @ 2022-10-03 11:08 UTC (permalink / raw)
To: GCC patches; +Cc: Andrew MacLeod, Aldy Hernandez
Currently if we have a range of [0,0] and we set the nonzero bits to
1, the current code pessimizes the range to [0,1] because it assumes
the range is [1,1] plus the possibility of 0. This fixes the
oversight.
gcc/ChangeLog:
* value-range.cc (irange::set_nonzero_bits): Do not pessimize range.
(range_tests_nonzero_bits): New test.
---
gcc/value-range.cc | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index e1066f4946e..6e196574de9 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -2934,6 +2934,14 @@ irange::set_nonzero_bits (const wide_int_ref &bits)
// range immediately.
if (wi::popcount (bits) == 1)
{
+ // Make sure we don't pessimize the range.
+ tree tbits = wide_int_to_tree (type (), bits);
+ if (!contains_p (tbits))
+ {
+ set_nonzero_bits (tbits);
+ return;
+ }
+
bool has_zero = contains_p (build_zero_cst (type ()));
set (type (), bits, bits);
if (has_zero)
@@ -3628,6 +3636,11 @@ range_tests_nonzero_bits ()
r1.set_nonzero_bits (0xff);
r0.union_ (r1);
ASSERT_TRUE (r0.varying_p ());
+
+ // Test that setting a nonzero bit of 1 does not pessimize the range.
+ r0.set_zero (integer_type_node);
+ r0.set_nonzero_bits (1);
+ ASSERT_TRUE (r0.zero_p ());
}
// Build an frange from string endpoints.
--
2.37.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-03 11:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-03 11:08 [COMMITTED] Do not compare incompatible ranges in ipa-prop Aldy Hernandez
2022-10-03 11:08 ` [COMMITTED] Do not compare nonzero masks for varying Aldy Hernandez
2022-10-03 11:08 ` [COMMITTED] Avoid comparing ranges when sub-ranges is 0 Aldy Hernandez
2022-10-03 11:08 ` [COMMITTED] Do not pessimize range in set_nonzero_bits 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).