From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 021EA3857811 for ; Fri, 15 Jan 2021 18:29:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 021EA3857811 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-554-pu50pJmuNQarsK9chS9fHw-1; Fri, 15 Jan 2021 13:29:38 -0500 X-MC-Unique: pu50pJmuNQarsK9chS9fHw-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 4BA6A107ACFC for ; Fri, 15 Jan 2021 18:29:37 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-64.ams2.redhat.com [10.36.112.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E6ABC10016FE for ; Fri, 15 Jan 2021 18:29:36 +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 10FITYEF3967117 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Fri, 15 Jan 2021 19:29:34 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 10FITX2Q3967116 for gcc-patches@gcc.gnu.org; Fri, 15 Jan 2021 19:29:33 +0100 Date: Fri, 15 Jan 2021 19:29:33 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] testsuite: Add testcase coverage for already fixed [PR96671] Message-ID: <20210115182933.GL1034503@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=3.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, UNWANTED_LANGUAGE_BODY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Level: *** X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Fri, 15 Jan 2021 18:29:44 -0000 Hi! The fix for this PR didn't come with any test coverage, I've added tests that make sure we optimize it no matter what order of the x ^ y ^ z operands is used. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2021-01-15 Jakub Jelinek PR tree-optimization/96671 * gcc.dg/tree-ssa/pr96671-1.c: New test. * gcc.dg/tree-ssa/pr96671-2.c: New test. --- gcc/testsuite/gcc.dg/tree-ssa/pr96671-1.c.jj 2021-01-15 14:44:54.694936995 +0100 +++ gcc/testsuite/gcc.dg/tree-ssa/pr96671-1.c 2021-01-15 14:45:40.248419337 +0100 @@ -0,0 +1,51 @@ +/* PR tree-optimization/96671 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " \\^ " 6 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " ~" 6 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " & " 6 "optimized" } } */ + +int +foo (int a, int b, int c) +{ + return (a ^ b) & ((b ^ c) ^ a); +} + +int +bar (int a, int b, int c) +{ + return (a ^ b) & ((b ^ a) ^ c); +} + +int +baz (int a, int b, int c) +{ + return (a ^ b) & ((a ^ c) ^ b); +} + +int +qux (int a, int b, int c) +{ + int d = a ^ b; + int e = b ^ c; + int f = e ^ a; + return d & f; +} + +int +corge (int a, int b, int c) +{ + int d = a ^ b; + int e = b ^ a; + int f = c ^ e; + return d & f; +} + +int +garply (int a, int b, int c) +{ + int d = a ^ b; + int e = a ^ c; + int f = b ^ e; + return d & f; +} --- gcc/testsuite/gcc.dg/tree-ssa/pr96671-2.c.jj 2021-01-15 14:44:57.665903235 +0100 +++ gcc/testsuite/gcc.dg/tree-ssa/pr96671-2.c 2021-01-15 14:45:49.565313469 +0100 @@ -0,0 +1,51 @@ +/* PR tree-optimization/96671 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " \\^ " 6 "optimized" } } */ +/* { dg-final { scan-tree-dump-not " ~" "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\| " 6 "optimized" } } */ + +int +foo (int a, int b, int c) +{ + return (a ^ b) | ((b ^ c) ^ a); +} + +int +bar (int a, int b, int c) +{ + return (a ^ b) | ((b ^ a) ^ c); +} + +int +baz (int a, int b, int c) +{ + return (a ^ b) | ((a ^ c) ^ b); +} + +int +qux (int a, int b, int c) +{ + int d = a ^ b; + int e = b ^ c; + int f = e ^ a; + return d | f; +} + +int +corge (int a, int b, int c) +{ + int d = a ^ b; + int e = b ^ a; + int f = c ^ e; + return d | f; +} + +int +garply (int a, int b, int c) +{ + int d = a ^ b; + int e = a ^ c; + int f = b ^ e; + return d | f; +} Jakub