diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-01-19 23:26:35 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-01-19 23:26:35 +0100 |
commit | c81e68a9cdbb5411dce1f1da3b35854212305c7c (patch) | |
tree | 0292d083c0f9a7a5c7dd76fa59a04c3dedc5f6df /gcc/value-relation.cc | |
parent | 77a67e3a9294c825ac1a2b205fbb266e7c29e82b (diff) | |
download | gcc-c81e68a9cdbb5411dce1f1da3b35854212305c7c.zip gcc-c81e68a9cdbb5411dce1f1da3b35854212305c7c.tar.gz gcc-c81e68a9cdbb5411dce1f1da3b35854212305c7c.tar.bz2 |
value-relation: Fix up relation_union [PR108447]
While looking at the PR, I've noticed one row in rr_union_table
is wrong. relation_union should be commutative, but due to that
bug is not. The following patch adds a self-test for that
property (fails without the first hunk) and fixes that line.
The actual floating point relation problem isn't fixed by this patch
though.
2023-01-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/108447
* value-relation.cc (rr_union_table): Fix VREL_UNDEFINED row order.
(relation_tests): Add self-tests for relation_{intersect,union}
commutativity.
* selftest.h (relation_tests): Declare.
* function-tests.cc (test_ranges): Call it.
Diffstat (limited to 'gcc/value-relation.cc')
-rw-r--r-- | gcc/value-relation.cc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index b8fa765..6f8a1b7 100644 --- a/gcc/value-relation.cc +++ b/gcc/value-relation.cc @@ -115,7 +115,7 @@ relation_kind rr_union_table[VREL_LAST][VREL_LAST] = { { VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING }, // VREL_UNDEFINED - { VREL_VARYING, VREL_LT, VREL_LE, VREL_GT, VREL_GE, VREL_UNDEFINED, + { VREL_VARYING, VREL_UNDEFINED, VREL_LT, VREL_LE, VREL_GT, VREL_GE, VREL_EQ, VREL_NE }, // VREL_LT { VREL_VARYING, VREL_LT, VREL_LT, VREL_LE, VREL_NE, VREL_VARYING, VREL_LE, @@ -1718,3 +1718,26 @@ equiv_relation_iterator::get_name (relation_kind *rel) } return NULL_TREE; } + +#if CHECKING_P +#include "selftest.h" + +namespace selftest +{ +void +relation_tests () +{ + // Verify commutativity of relation_intersect and relation_union. + for (relation_kind r1 = VREL_VARYING; r1 < VREL_PE8; + r1 = relation_kind (r1 + 1)) + for (relation_kind r2 = VREL_VARYING; r2 < VREL_PE8; + r2 = relation_kind (r2 + 1)) + { + ASSERT_EQ (relation_intersect (r1, r2), relation_intersect (r2, r1)); + ASSERT_EQ (relation_union (r1, r2), relation_union (r2, r1)); + } +} + +} // namespace selftest + +#endif // CHECKING_P |