public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5264] value-relation: Fix up relation_union [PR108447] Date: Thu, 19 Jan 2023 22:27:09 +0000 (GMT) [thread overview] Message-ID: <20230119222709.78A653858C54@sourceware.org> (raw) https://gcc.gnu.org/g:c81e68a9cdbb5411dce1f1da3b35854212305c7c commit r13-5264-gc81e68a9cdbb5411dce1f1da3b35854212305c7c Author: Jakub Jelinek <jakub@redhat.com> Date: Thu Jan 19 23:26:35 2023 +0100 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. Diff: --- gcc/function-tests.cc | 1 + gcc/selftest.h | 1 + gcc/value-relation.cc | 25 ++++++++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/gcc/function-tests.cc b/gcc/function-tests.cc index 846226d99e2..39970b2fcfd 100644 --- a/gcc/function-tests.cc +++ b/gcc/function-tests.cc @@ -583,6 +583,7 @@ test_ranges () push_cfun (fun); range_tests (); range_op_tests (); + relation_tests (); build_cfg (fndecl); convert_to_ssa (fndecl); diff --git a/gcc/selftest.h b/gcc/selftest.h index 1abec2dd69b..20d522afda4 100644 --- a/gcc/selftest.h +++ b/gcc/selftest.h @@ -244,6 +244,7 @@ extern void predict_cc_tests (); extern void pretty_print_cc_tests (); extern void range_tests (); extern void range_op_tests (); +extern void relation_tests (); extern void gimple_range_tests (); extern void read_rtl_function_cc_tests (); extern void rtl_tests_cc_tests (); diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index b8fa7653232..6f8a1b7e7d3 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
reply other threads:[~2023-01-19 22:27 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230119222709.78A653858C54@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).