From patchwork Thu Jan 19 20:16:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 63422 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 16B833858C27 for ; Thu, 19 Jan 2023 20:17:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16B833858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674159448; bh=Lv9tfoKKUEvJVuPI32NGZb4F8QeCHPFkchTVDuHKYLs=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ShdB21zmopwR7iJgEYgHvuokbX3DtY/XicWn65rxT2PG6XuOiRZyCcFhrrqujkEnj WV8DdnapUaItxzUmaRZT8fsAAVn3k6iPc4m8dCBdkUuqYQsLeA/8Bm2g+ORwsltcMF SLEGGfmZdwy6rxrn/07xpvgKdmlVp29zuKVlREts= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 34EF03858C52 for ; Thu, 19 Jan 2023 20:17:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 34EF03858C52 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-189-hUSv3gzxOje-LDljujzRPw-1; Thu, 19 Jan 2023 15:16:56 -0500 X-MC-Unique: hUSv3gzxOje-LDljujzRPw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A23685CCE5 for ; Thu, 19 Jan 2023 20:16:56 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 239862026D68; Thu, 19 Jan 2023 20:16:56 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 30JKGrIi3366316 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 19 Jan 2023 21:16:53 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30JKGr7I3366315; Thu, 19 Jan 2023 21:16:53 +0100 Date: Thu, 19 Jan 2023 21:16:52 +0100 To: Aldy Hernandez , Andrew MacLeod Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] value-relation: Fix up relation_union [PR108447] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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 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. Jakub --- gcc/value-relation.cc.jj 2023-01-19 18:33:47.296304283 +0100 +++ gcc/value-relation.cc 2023-01-19 18:41:24.280658434 +0100 @@ -115,7 +115,7 @@ relation_kind rr_union_table[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 (relat } 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 --- gcc/selftest.h.jj 2023-01-02 09:32:34.083116265 +0100 +++ gcc/selftest.h 2023-01-19 18:38:58.267781163 +0100 @@ -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 (); --- gcc/function-tests.cc.jj 2023-01-02 09:32:51.941858230 +0100 +++ gcc/function-tests.cc 2023-01-19 18:39:13.942553180 +0100 @@ -583,6 +583,7 @@ test_ranges () push_cfun (fun); range_tests (); range_op_tests (); + relation_tests (); build_cfg (fndecl); convert_to_ssa (fndecl);