On 1/19/23 15:16, Jakub Jelinek wrote:
Hi! 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. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? The actual floating point relation problem isn't fixed by this patch though. 2023-01-19 Jakub Jelinek <ja...@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. <...>
+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)); + } +}
Easy test, I like it.