From patchwork Fri May 26 01:48:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 70107 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 B62493858C54 for ; Fri, 26 May 2023 01:49:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B62493858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685065763; bh=wa12C35Boma3XsM0ourUcCG4rxQMBLfasxVP5LNhI68=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=gb0WS4MDXY3+yw0prWE/SBbooI/XcL3H1flENYoBhwgozDnFahqSjlO/i6CN0nQxn CsBoMX/Vg9aZ+0gV610HfnzEYQc0OKyszhlfVM7u/SKLGlDcUuNTGkz1L3LeKyB+3P Q7sZqc19rrul0bm6ViReNtkVzaAlxXppB0v7NwVI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id BF9D23858D39 for ; Fri, 26 May 2023 01:48:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF9D23858D39 X-IronPort-AV: E=McAfee;i="6600,9927,10721"; a="440438437" X-IronPort-AV: E=Sophos;i="6.00,192,1681196400"; d="scan'208";a="440438437" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2023 18:48:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10721"; a="735800857" X-IronPort-AV: E=Sophos;i="6.00,192,1681196400"; d="scan'208";a="735800857" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga008.jf.intel.com with ESMTP; 25 May 2023 18:48:50 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 9FA4A1005138; Fri, 26 May 2023 09:48:49 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: crazylht@gmail.com, hjl.tools@gmail.com Subject: [PATCH] [x86] Split notl + pbraodcast + pand to pbroadcast + pandn more modes. Date: Fri, 26 May 2023 09:48:49 +0800 Message-Id: <20230526014849.429796-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.39.1.388.g2fc9e9ca3c MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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: liuhongt via Gcc-patches From: liuhongt Reply-To: liuhongt Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" r12-5595-gc39d77f252e895306ef88c1efb3eff04e4232554 adds 2 splitter to transform notl + pbroadcast + pand to pbroadcast + pandn for VI124_AVX2 which leaves out all DI-element-size ones as well as all 512-bit ones. This patch extend the splitter to VI_AVX2 which will handle DImode for AVX2, and V64QImode,V32HImode,V16SImode,V8DImode for AVX512. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ready to push to trunk. gcc/ChangeLog: PR target/100711 * config/i386/sse.md (*andnot3): Extend below splitter to VI_AVX2 to cover more modes. gcc/testsuite/ChangeLog: * gcc.target/i386/pr100711-2.c: Add v4di/v2di testcases. * gcc.target/i386/pr100711-3.c: New test. --- gcc/config/i386/sse.md | 12 +++---- gcc/testsuite/gcc.target/i386/pr100711-2.c | 14 +++++++- gcc/testsuite/gcc.target/i386/pr100711-3.c | 40 ++++++++++++++++++++++ 3 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr100711-3.c diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 26dd0b1aa10..97f883d8083 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -17116,17 +17116,17 @@ (define_split ;; PR target/100711: Split notl; vpbroadcastd; vpand as vpbroadcastd; vpandn (define_split - [(set (match_operand:VI124_AVX2 0 "register_operand") - (and:VI124_AVX2 - (vec_duplicate:VI124_AVX2 + [(set (match_operand:VI_AVX2 0 "register_operand") + (and:VI_AVX2 + (vec_duplicate:VI_AVX2 (not: (match_operand: 1 "register_operand"))) - (match_operand:VI124_AVX2 2 "vector_operand")))] + (match_operand:VI_AVX2 2 "vector_operand")))] "TARGET_AVX2" [(set (match_dup 3) - (vec_duplicate:VI124_AVX2 (match_dup 1))) + (vec_duplicate:VI_AVX2 (match_dup 1))) (set (match_dup 0) - (and:VI124_AVX2 (not:VI124_AVX2 (match_dup 3)) + (and:VI_AVX2 (not:VI_AVX2 (match_dup 3)) (match_dup 2)))] "operands[3] = gen_reg_rtx (mode);") diff --git a/gcc/testsuite/gcc.target/i386/pr100711-2.c b/gcc/testsuite/gcc.target/i386/pr100711-2.c index ccaf1688e19..f75914fb7fc 100644 --- a/gcc/testsuite/gcc.target/i386/pr100711-2.c +++ b/gcc/testsuite/gcc.target/i386/pr100711-2.c @@ -4,10 +4,12 @@ typedef char v16qi __attribute__ ((vector_size (16))); typedef short v8hi __attribute__ ((vector_size (16))); typedef int v4si __attribute__ ((vector_size (16))); +typedef long long v2di __attribute__((vector_size (16))); typedef char v32qi __attribute__ ((vector_size (32))); typedef short v16hi __attribute__ ((vector_size (32))); typedef int v8si __attribute__ ((vector_size (32))); +typedef long long v4di __attribute__((vector_size (32))); v16qi foo_v16qi (char a, v16qi b) { @@ -25,6 +27,11 @@ v4si foo_v4si (int a, v4si b) return (__extension__ (v4si) {~a, ~a, ~a, ~a}) & b; } +v2di foo_v2di (long long a, v2di b) +{ + return (__extension__ (v2di) {~a, ~a}) & b; +} + v32qi foo_v32qi (char a, v32qi b) { return (__extension__ (v32qi) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, @@ -44,4 +51,9 @@ v8si foo_v8si (int a, v8si b) return (__extension__ (v8si) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,}) & b; } -/* { dg-final { scan-assembler-times "vpandn" 6 } } */ +v4di foo_v4di (long long a, v4di b) +{ + return (__extension__ (v4di) {~a, ~a, ~a, ~a}) & b; +} + +/* { dg-final { scan-assembler-times "vpandn" 8 } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr100711-3.c b/gcc/testsuite/gcc.target/i386/pr100711-3.c new file mode 100644 index 00000000000..e90f2a48d8d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr100711-3.c @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512bw" } */ + +typedef char v64qi __attribute__ ((vector_size (64))); +typedef short v32hi __attribute__ ((vector_size (64))); +typedef int v16si __attribute__ ((vector_size (64))); +typedef long long v8di __attribute__((vector_size (64))); + +v64qi foo_v64qi (char a, v64qi b) +{ + return (__extension__ (v64qi) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, + ~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, + ~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, + ~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, + ~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, + ~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, + ~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, + ~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) & b; +} + +v32hi foo_v32hi (short a, v32hi b) +{ + return (__extension__ (v32hi) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, + ~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, + ~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, + ~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) & b; +} + +v16si foo_v16si (int a, v16si b) +{ + return (__extension__ (v16si) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a, + ~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) & b; +} + +v8di foo_v8di (long long a, v8di b) +{ + return (__extension__ (v8di) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) & b; +} + +/* { dg-final { scan-assembler-times "vpandn" 4 } } */