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: 45956 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp526172wrn; Thu, 19 Jan 2023 12:17:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXugAIMeblvDtGUhnpKgQ9nsCOrM7joxiqekQCcEpAa+fLlFbwxHPJpmgSfCi27BZlRUoPSf X-Received: by 2002:a17:907:8a1d:b0:84d:3822:2fc7 with SMTP id sc29-20020a1709078a1d00b0084d38222fc7mr16068323ejc.77.1674159463884; Thu, 19 Jan 2023 12:17:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674159463; cv=none; d=google.com; s=arc-20160816; b=bwyf79MCBlaFZc2XaKHsCb76gKsp5IPYTZp5vSuDY0O7NTctlgw4kHb9RVPjOzrRvP 55E0UIiUyhfxMvZz9qqpVQrBnbYCfyvXE4El6D5Rd2wWrHRoFgeQRDu6XBACKCVa5uv8 fOU6MA4It8TAn28ihKgE3ciR1NTA4UPy/VONQ0xDtFsmpidq0gcjm0objf/rMf5cXloo P4f7cflEIWwPyOi/Lomuo2DyPixMx1xGmF+j7w/tg43t1L4fYdTC1UYhPCczuI+mole7 x5c1lyo28ke0jzuUmCiGja3fwZzFHLAEtpiC8lgQ784SWzncOPFDDIWKQTdqcerLp5Fc NoFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Lv9tfoKKUEvJVuPI32NGZb4F8QeCHPFkchTVDuHKYLs=; b=UlagZLIvVxfyOtkC+CdFxtebS4E7C53CGVsHEszd8c1UKKD1JG3XZEz+jAa0KR8B5A 5JiX6F6tbLZqOatsFWbwGstaxPJCJGgtT00tdKVgkC8+TX/olcGSkU50YbJ42cGKtgBL FAIpBDjQJmMqxKzz4yXRqZylk9oGFWCirxoe5i+r2cToCr6NwXG+7HNyiedNitUqcNmH cBpfE8l8/2B5voXgSktjUdrfzjuxKLhG+eA60iiNLDyuslZZOGZA4CHa+3TvrqIdm9jz OUKeYZw6Fi3LDJkA+6H61mtjH32+2fpWegPrUCLriRsk9VoRC0ZsBJ9WfbSv5VIun7gL 4MQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TCYGN4Ao; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id xb13-20020a170907070d00b0084d1310711dsi42801440ejb.315.2023.01.19.12.17.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 12:17:43 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TCYGN4Ao; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 934453858434 for ; Thu, 19 Jan 2023 20:17:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 934453858434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674159462; bh=Lv9tfoKKUEvJVuPI32NGZb4F8QeCHPFkchTVDuHKYLs=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=TCYGN4AobZD9LZ967aTlA3mVmOQ209l7wsLHdeiBDe7WqGZUSJMufxNDDwGXQvV4F jowQ//kUPNAud9pfFIJ4lap5lb9My4spv5u5zOv1BLf2AvNbYinTr4lWTZiWcRgNGI 0S2KETEeS5DulTSMKTLcPupRxTCdjGAb5V4ic9U8= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755483434032226010?= X-GMAIL-MSGID: =?utf-8?q?1755483434032226010?= 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);