From patchwork Sat Jan 29 16:46:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1586219 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Tuj9fHb1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JmKyH0sn7z9sSs for ; Sun, 30 Jan 2022 03:48:05 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7B2FB3858001 for ; Sat, 29 Jan 2022 16:48:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B2FB3858001 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1643474882; bh=ZMJQN/wYdZn8ZnkIjBMI4oQDTY1j1spyGBgtQLcSqwo=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Tuj9fHb1LpgJyaYyDUMCvppjrTEGnqenaxxgYBcaOfh2p0yzyilyfs7XPikYMjr90 +afnehyVIdyQR8fy/Wde5RYVFCj6XwLg6kTGRa6nZTZrAKYuO6yikgG1PG6hz4K8bU 0tEtoQExX6v7IIOtxgd86KjENTne09uhuZfGiQFc= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 678AA3858402 for ; Sat, 29 Jan 2022 16:46:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 678AA3858402 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-542-_7m5tFuaPJ2nTX_j4NZYHg-1; Sat, 29 Jan 2022 11:46:15 -0500 X-MC-Unique: _7m5tFuaPJ2nTX_j4NZYHg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB4AE801B0B; Sat, 29 Jan 2022 16:46:14 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3582810A4B39; Sat, 29 Jan 2022 16:46:14 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 20TGkBQ63408246 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 29 Jan 2022 17:46:11 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 20TGk9nu3408244; Sat, 29 Jan 2022 17:46:09 +0100 Date: Sat, 29 Jan 2022 17:46:09 +0100 To: Richard Biener , Jeff Law Subject: [PATCH] testsuite: Fix up tree-ssa/pr103514.c testcase [PR103514] Message-ID: <20220129164609.GX2646553@tucnak> References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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 Cc: "gcc-patches@gcc.gnu.org" Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" On Fri, Jan 28, 2022 at 03:14:16PM -0700, Jeff Law via Gcc-patches wrote: > > This patch will add the missed pattern described in bug 103514 [1] to the match.pd. [1] includes proof of correctness for the patch too. > > > > PR tree-optimization/103514 > > * match.pd (a & b) ^ (a == b) -> !(a | b): New optimization. > > * match.pd (a & b) == (a ^ b) -> !(a | b): New optimization. > > * gcc.dg/tree-ssa/pr103514.c: Testcase for this optimization. > > > > 1) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103514 > Note the bug was filed an fixed during stage3, review just didn't happen in > a reasonable timeframe. > > I'm going to ACK this for the trunk and go ahead and commit it for you. The testcase FAILs on short-circuit targets like powerpc64le-linux. While the first 2 functions are identical, the last two look like: : if (a_5(D) != 0) goto ; [INV] else goto ; [INV] : if (b_6(D) != 0) goto ; [INV] else goto ; [INV] : : # iftmp.1_4 = PHI <1(3), 0(4)> _1 = a_5(D) == b_6(D); _2 = (int) _1; _3 = _2 ^ iftmp.1_4; _9 = _2 != iftmp.1_4; return _9; instead of the expected: : _3 = a_8(D) & b_9(D); _4 = (int) _3; _5 = a_8(D) == b_9(D); _6 = (int) _5; _1 = a_8(D) | b_9(D); _2 = ~_1; _7 = (int) _2; _10 = ~_1; return _10; so no wonder it doesn't match. E.g. x86_64-linux will also use jumps if it isn't just a && b but a && b && c && d (will do a & b and c & d tests and jump based on those. As it is too late to implement this optimization even for the short circuiting targets this late (not even sure which pass would be best), this patch just forces non-short-circuiting for the test. Tested on x86_64-linux -m32/-m64 and powerpc64le-linux, ok for trunk? 2022-01-29 Jakub Jelinek PR tree-optimization/103514 * gcc.dg/tree-ssa/pr103514.c: Add --param logical-op-non-short-circuit=1 to dg-options. Jakub --- gcc/testsuite/gcc.dg/tree-ssa/pr103514.c.jj 2022-01-29 11:11:39.338627697 +0100 +++ gcc/testsuite/gcc.dg/tree-ssa/pr103514.c 2022-01-29 17:37:18.255237211 +0100 @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -fdump-tree-optimized" } */ +/* { dg-options "-O --param logical-op-non-short-circuit=1 -fdump-tree-optimized" } */ #include bool @@ -30,4 +30,4 @@ h (bool a, bool b) /* Make sure we have removed "==" and "^" and "&". */ /* { dg-final { scan-tree-dump-not "&" "optimized"} } */ /* { dg-final { scan-tree-dump-not "\\^" "optimized"} } */ -/* { dg-final { scan-tree-dump-not "==" "optimized"} } */ \ No newline at end of file +/* { dg-final { scan-tree-dump-not "==" "optimized"} } */