From patchwork Tue Jul 4 18:25:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 115882 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1395124vqx; Tue, 4 Jul 2023 11:25:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlG7PSp5Rh5E2WeARU35aWE4SYE52pcbthYFpVbHa8OC5r4/D8WReqAjnuJYo2X1gf7p2ukQ X-Received: by 2002:aa7:c249:0:b0:51d:91d2:334d with SMTP id y9-20020aa7c249000000b0051d91d2334dmr9619604edo.15.1688495147373; Tue, 04 Jul 2023 11:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688495147; cv=none; d=google.com; s=arc-20160816; b=0kNTIl9uzaYK4ghoReL1f3dXfcKP/Body8xJ8XFtj43WIItcP7AqOIRGUhJ/A1QunE 2GsMCktEEmFD3efzVimdPLtvhpKUBapMlq8HhI5KXm9LVmlT97sS9O2pLvdKZoiieGQa FcZUPvaatyYzlR4rQ/Xh0F4X4sM4l1S1+K6LFcuRf2I1N+A3UK04v1oXPd531M5rd6fO tdSvcgZGAL96SsxpCO0ZOgMIcwDVGdX8I52mJICZCULgATn3Eo0el7Gi6pGwauvHk+Qe NdCPEkB+xAwmgx23D8exxYMn0tLG808aXkByRBVjUfCXwkM0ot096EQElolaRVIB01ak lHuQ== 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:message-id :user-agent:subject:to:date:mime-version:dkim-filter:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=Su6UihWwQqzSEZ32/Kyc+hoxBTB8+lOADetkwo/aUfs=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=l7yHo7V9yZgOFGiMPty8i5uycTYJI162rJ798jhFUTChTw4hx+N2E5FQUJ/7TO62M2 Jr3M3rqaMT37wzrNLFWAFcm+upf/j7ZsVsKN7itcmO/Ym4FYr2eVsXDVInIKErNRuz2v Wdu5lV+D5ipnt/MJDhiq77327XC4c+B+sM1Ag5PQn4jEi1eUpMtPsMbz6Pq4i9AsMW66 XXcY5IC0YqVxxnuiaE253pNQbosrAkIA6ie8WxdwTiQo8mV/BYf6tBJmJpvwpwnMuFlx vUk5ZOBXTEI4YOLc6UuzP5J/jPeWYYs9wfnjMDJl5BsfWKd7WnOp0uavwIU/V7RCdhGm qKQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="ap6bn/q5"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ba11-20020a0564021acb00b0051dd3a8c40fsi7801656edb.213.2023.07.04.11.25.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 11:25:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="ap6bn/q5"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 3068B385843A for ; Tue, 4 Jul 2023 18:25:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3068B385843A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688495146; bh=Su6UihWwQqzSEZ32/Kyc+hoxBTB8+lOADetkwo/aUfs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ap6bn/q5bmCDxaJWtlvbjLsJA3kPT5rl3CEsFrxtS65LdtknXQxb1u29ARS1dn9Li d213w/vdc+9d7d0HOLHasd3CR7gaUXGwZMLOHA0hdjDxr0YqzeU4Wb2scuCRCvHStv D+kj9HlqlQCQHPjQ3i7is4AurwOJ4wHQfGmhkvHs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id 4435A3857723 for ; Tue, 4 Jul 2023 18:25:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4435A3857723 Received: from mail.ispras.ru (unknown [83.149.199.84]) by mail.ispras.ru (Postfix) with ESMTPSA id B452740769DA for ; Tue, 4 Jul 2023 18:25:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru B452740769DA MIME-Version: 1.0 Date: Tue, 04 Jul 2023 21:25:00 +0300 To: gcc-patches@gcc.gnu.org Subject: Generating all-ones zmm needs dep-breaking pxor before ternlog (PR target/110438) User-Agent: Roundcube Webmail/1.4.13 Message-ID: <8f73371d732237ed54ede44b7bd88624@ispras.ru> X-Sender: simonaytes.yan@ispras.ru X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: "simonaytes.yan--- via Gcc-patches" From: "Li, Pan2 via Gcc-patches" Reply-To: simonaytes.yan@ispras.ru 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?1770515487487510866?= X-GMAIL-MSGID: =?utf-8?q?1770515487487510866?= PR target/110438 requests to emit PXOR before VPTERNLOG. This patch implements that. From 815779936d0ca213b4c9ec798ed6acf8179fc2e7 Mon Sep 17 00:00:00 2001 From: Yan Simonaytes Date: Tue, 4 Jul 2023 21:11:04 +0300 Subject: [PATCH] Generating all-ones zmm needs dep-breaking pxor before ternlog PR target/110438 gcc/ChangeLog: * config/i386/i386.cc (standard_sse_constant_opcode): Emit PXOR before VPTERNLOG. gcc/testsuite/ChangeLog: * gcc.target/i386/pr110438-1.c: New test. * gcc.target/i386/pr110438-2.c: New test. * gcc.target/i386/pr110438-3.c: New test. --- gcc/config/i386/i386.cc | 23 +++++++++++++++++++--- gcc/testsuite/gcc.target/i386/pr110438-1.c | 12 +++++++++++ gcc/testsuite/gcc.target/i386/pr110438-2.c | 12 +++++++++++ gcc/testsuite/gcc.target/i386/pr110438-3.c | 12 +++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr110438-1.c create mode 100644 gcc/testsuite/gcc.target/i386/pr110438-2.c create mode 100644 gcc/testsuite/gcc.target/i386/pr110438-3.c diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 8989985700a..89e0072caa1 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -5329,6 +5329,13 @@ standard_sse_constant_opcode (rtx_insn *insn, rtx *operands) case MODE_V8DF: case MODE_V16SF: gcc_assert (TARGET_AVX512F); + if (optimize_insn_for_speed_p ()) + { + if (TARGET_AVX512VL) + output_asm_insn ("vpxor\t%x0, %x0, %x0", operands); + else + output_asm_insn ("vpxor\t%g0, %g0, %g0", operands); + } return "vpternlogd\t{$0xFF, %g0, %g0, %g0|%g0, %g0, %g0, 0xFF}"; case MODE_OI: @@ -5344,10 +5351,20 @@ standard_sse_constant_opcode (rtx_insn *insn, rtx *operands) return (TARGET_AVX ? "vpcmpeqd\t%0, %0, %0" : "pcmpeqd\t%0, %0"); - else if (TARGET_AVX512VL) - return "vpternlogd\t{$0xFF, %0, %0, %0|%0, %0, %0, 0xFF}"; else - return "vpternlogd\t{$0xFF, %g0, %g0, %g0|%g0, %g0, %g0, 0xFF}"; + { + if (optimize_insn_for_speed_p ()) + { + if (TARGET_AVX512VL) + output_asm_insn ("vpxor\t%x0, %x0, %x0", operands); + else + output_asm_insn ("vpxor\t%g0, %g0, %g0", operands); + } + if (TARGET_AVX512VL) + return "vpternlogd\t{$0xFF, %0, %0, %0|%0, %0, %0, 0xFF}"; + else + return "vpternlogd\t{$0xFF, %g0, %g0, %g0|%g0, %g0, %g0, 0xFF}"; + } default: gcc_unreachable (); diff --git a/gcc/testsuite/gcc.target/i386/pr110438-1.c b/gcc/testsuite/gcc.target/i386/pr110438-1.c new file mode 100644 index 00000000000..0c5f4470e9e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr110438-1.c @@ -0,0 +1,12 @@ +/* PR target/110438 generating all-ones zmm needs dep-breaking pxor before ternlog */ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ + +typedef int v64 __attribute__((vector_size(64))); + +v64 g(void) +{ + return (v64){0} - 1; +} + +/* { dg-final { scan-assembler "vpxor\t%z" } }*/ diff --git a/gcc/testsuite/gcc.target/i386/pr110438-2.c b/gcc/testsuite/gcc.target/i386/pr110438-2.c new file mode 100644 index 00000000000..14770a972e6 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr110438-2.c @@ -0,0 +1,12 @@ +/* PR target/110438 generating all-ones zmm needs dep-breaking pxor before ternlog */ +/* { dg-do compile } */ +/* { dg-options "-mavx512vl -O2" } */ + +typedef int v64 __attribute__((vector_size(64))); + +v64 g(void) +{ + return (v64){0} - 1; +} + +/* { dg-final { scan-assembler "vpxor\t%x" } }*/ diff --git a/gcc/testsuite/gcc.target/i386/pr110438-3.c b/gcc/testsuite/gcc.target/i386/pr110438-3.c new file mode 100644 index 00000000000..fb07997839c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr110438-3.c @@ -0,0 +1,12 @@ +/* PR target/110438 generating all-ones zmm needs dep-breaking pxor before ternlog */ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -Os" } */ + +typedef int v64 __attribute__((vector_size(64))); + +v64 g(void) +{ + return (v64){0} - 1; +} + +/* { dg-final { scan-assembler-not "vpxor" } }*/ -- 2.34.1