From patchwork Wed Aug 5 02:40:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 1341052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: 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=fktomQBx; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4BLwpQ0Jcfz9sR4 for ; Wed, 5 Aug 2020 12:40:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2C840386103E; Wed, 5 Aug 2020 02:40:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C840386103E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1596595223; bh=eqndyF60dw3sSJ6+0NpncQ+27OaQbdKD3eBZwmJaEPI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fktomQBxE/+BQGgOSg1lrXe7O953qTwJ0RvU/9WyijslXk4kXrn59ljN26gYGKamR L+VSt5R4PrzgX4DeOBJBhTdYQeA6e6FftOiMoeoJQw7qP9yQzikUVWU5Z5/wdJwLg2 2w4z1OAqpSAdJO6CKyxcRlvPhA3aFeU0Gc5a/2sQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id BE2DF3858D37 for ; Wed, 5 Aug 2020 02:40:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BE2DF3858D37 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0752W2Q7041030; Tue, 4 Aug 2020 22:40:20 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 32qkfp8x12-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Aug 2020 22:40:20 -0400 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 0752W84n041272; Tue, 4 Aug 2020 22:40:19 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0b-001b2d01.pphosted.com with ESMTP id 32qkfp8x0w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Aug 2020 22:40:19 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0752ZdkJ022571; Wed, 5 Aug 2020 02:40:19 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma02wdc.us.ibm.com with ESMTP id 32n01958t0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Aug 2020 02:40:19 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0752eEEr54853990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Aug 2020 02:40:14 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 405BC7805F; Wed, 5 Aug 2020 02:40:18 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AABF97805E; Wed, 5 Aug 2020 02:40:17 +0000 (GMT) Received: from ibm-tinman.the-meissners.org (unknown [9.160.3.19]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTPS; Wed, 5 Aug 2020 02:40:17 +0000 (GMT) Date: Tue, 4 Aug 2020 22:40:15 -0400 To: gcc-patches@gcc.gnu.org, Segher Boessenkool , David Edelsohn , Michael Meissner Subject: [PATCH] Power10: Add BRH, BRW, BRD support. Message-ID: <20200805024015.GA22456@ibm-tinman.the-meissners.org> Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, Segher Boessenkool , David Edelsohn MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-08-04_09:2020-08-03, 2020-08-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 spamscore=0 suspectscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 clxscore=1015 bulkscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008050016 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 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-Patchwork-Original-From: Michael Meissner via Gcc-patches From: Michael Meissner Reply-To: Michael Meissner Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Power10: Add BRH, BRW, BRD support. The power10 processor adds 3 new instructions (BRH, BRW, BRD) that byte swaps half-words, words, and double-words within a GPR register. This patch adds support for these instructions. I have applied the suggestions from the previous times I have submitted this patch. I have done bootstrap builds on a Linux power8 system. I have run the regression tests, and there were no regressions, and the 3 new tests pass. Can I check this into the master branch? gcc/ 2020-08-04 Michael Meissner * config/rs6000/rs6000.md (bswaphi2_reg): Generate the BRH instruction on ISA 3.1. (bswapsi2_reg): Generate the BRW instruction on ISA 3.1. (bswapdi2): Rename bswapdi2_xxbrd to bswapdi2_brd. (bswapdi2_brd): Rename from bswapdi2_xxbrd. Generate the BRD instruction on ISA 3.1. gcc/testsuite/ 2020-08-04 Michael Meissner * gcc.target/powerpc/bswap-brd.c: New test. * gcc.target/powerpc/bswap-brw.c: New test. * gcc.target/powerpc/bswap-brh.c: New test. --- gcc/config/rs6000/rs6000.md | 44 +++++++++++++++------------- gcc/testsuite/gcc.target/powerpc/bswap-brd.c | 23 +++++++++++++++ gcc/testsuite/gcc.target/powerpc/bswap-brh.c | 11 +++++++ gcc/testsuite/gcc.target/powerpc/bswap-brw.c | 22 ++++++++++++++ 4 files changed, 80 insertions(+), 20 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/bswap-brd.c create mode 100644 gcc/testsuite/gcc.target/powerpc/bswap-brh.c create mode 100644 gcc/testsuite/gcc.target/powerpc/bswap-brw.c diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 48f1f1c..43b620a 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -2591,15 +2591,16 @@ (define_insn "bswap2_store" [(set_attr "type" "store")]) (define_insn_and_split "bswaphi2_reg" - [(set (match_operand:HI 0 "gpc_reg_operand" "=&r,wa") + [(set (match_operand:HI 0 "gpc_reg_operand" "=r,&r,wa") (bswap:HI - (match_operand:HI 1 "gpc_reg_operand" "r,wa"))) - (clobber (match_scratch:SI 2 "=&r,X"))] + (match_operand:HI 1 "gpc_reg_operand" "r,r,wa"))) + (clobber (match_scratch:SI 2 "=X,&r,X"))] "" "@ + brh %0,%1 # xxbrh %x0,%x1" - "reload_completed && int_reg_operand (operands[0], HImode)" + "reload_completed && !TARGET_POWER10 && int_reg_operand (operands[0], HImode)" [(set (match_dup 3) (and:SI (lshiftrt:SI (match_dup 4) (const_int 8)) @@ -2615,21 +2616,22 @@ (define_insn_and_split "bswaphi2_reg" operands[3] = simplify_gen_subreg (SImode, operands[0], HImode, 0); operands[4] = simplify_gen_subreg (SImode, operands[1], HImode, 0); } - [(set_attr "length" "12,4") - (set_attr "type" "*,vecperm") - (set_attr "isa" "*,p9v")]) + [(set_attr "length" "*,12,*") + (set_attr "type" "shift,*,vecperm") + (set_attr "isa" "p10,*,p9v")]) ;; We are always BITS_BIG_ENDIAN, so the bit positions below in ;; zero_extract insns do not change for -mlittle. (define_insn_and_split "bswapsi2_reg" - [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,wa") + [(set (match_operand:SI 0 "gpc_reg_operand" "=r,&r,wa") (bswap:SI - (match_operand:SI 1 "gpc_reg_operand" "r,wa")))] + (match_operand:SI 1 "gpc_reg_operand" "r,r,wa")))] "" "@ + brw %0,%1 # xxbrw %x0,%x1" - "reload_completed && int_reg_operand (operands[0], SImode)" + "reload_completed && !TARGET_POWER10 && int_reg_operand (operands[0], SImode)" [(set (match_dup 0) ; DABC (rotate:SI (match_dup 1) (const_int 24))) @@ -2646,9 +2648,9 @@ (define_insn_and_split "bswapsi2_reg" (and:SI (match_dup 0) (const_int -256))))] "" - [(set_attr "length" "12,4") - (set_attr "type" "*,vecperm") - (set_attr "isa" "*,p9v")]) + [(set_attr "length" "4,12,4") + (set_attr "type" "shift,*,vecperm") + (set_attr "isa" "p10,*,p9v")]) ;; On systems with LDBRX/STDBRX generate the loads/stores directly, just like ;; we do for L{H,W}BRX and ST{H,W}BRX above. If not, we have to generate more @@ -2681,7 +2683,7 @@ (define_expand "bswapdi2" emit_insn (gen_bswapdi2_store (dest, src)); } else if (TARGET_P9_VECTOR) - emit_insn (gen_bswapdi2_xxbrd (dest, src)); + emit_insn (gen_bswapdi2_brd (dest, src)); else emit_insn (gen_bswapdi2_reg (dest, src)); DONE; @@ -2712,13 +2714,15 @@ (define_insn "bswapdi2_store" "stdbrx %1,%y0" [(set_attr "type" "store")]) -(define_insn "bswapdi2_xxbrd" - [(set (match_operand:DI 0 "gpc_reg_operand" "=wa") - (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "wa")))] +(define_insn "bswapdi2_brd" + [(set (match_operand:DI 0 "gpc_reg_operand" "=r,wa") + (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "r,wa")))] "TARGET_P9_VECTOR" - "xxbrd %x0,%x1" - [(set_attr "type" "vecperm") - (set_attr "isa" "p9v")]) + "@ + brd %0,%1 + xxbrd %x0,%x1" + [(set_attr "type" "shift,vecperm") + (set_attr "isa" "p10,p9v")]) (define_insn "bswapdi2_reg" [(set (match_operand:DI 0 "gpc_reg_operand" "=&r") diff --git a/gcc/testsuite/gcc.target/powerpc/bswap-brd.c b/gcc/testsuite/gcc.target/powerpc/bswap-brd.c new file mode 100644 index 0000000..876129e --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/bswap-brd.c @@ -0,0 +1,23 @@ +/* { dg-do compile { target { lp64 } } } */ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ + +/* This tests whether GCC generates the ISA 3.1 BRW byte swap instruction for + GPR data, but generates XXBRW for data in a vector register. */ + +unsigned long long +bswap_ll (unsigned long long a) +{ + return __builtin_bswap64 (a); /* { dg-final { scan-assembler {\mbrd\M} } } */ +} + +double +bswap_ll_dbl (unsigned long long a) +{ + unsigned int b = a; + /* Force the value to be loaded into a vector register. */ + __asm__ (" # %x0" : "+wa" (b)); + + /* { dg-final { scan-assembler {\mxxbrd\M} } } */ + return (double) __builtin_bswap64 (b); +} diff --git a/gcc/testsuite/gcc.target/powerpc/bswap-brh.c b/gcc/testsuite/gcc.target/powerpc/bswap-brh.c new file mode 100644 index 0000000..4dbab12 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/bswap-brh.c @@ -0,0 +1,11 @@ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ + +/* This tests whether GCC generates the ISA 3.1 16-bit byte swap + instruction BRH. */ + +unsigned short +bswap_short (unsigned short a) +{ + return __builtin_bswap16 (a); /* { dg-final { scan-assembler {\mbrh\M} } } */ +} diff --git a/gcc/testsuite/gcc.target/powerpc/bswap-brw.c b/gcc/testsuite/gcc.target/powerpc/bswap-brw.c new file mode 100644 index 0000000..b3f923e --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/bswap-brw.c @@ -0,0 +1,22 @@ +/* { dg-require-effective-target power10_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power10" } */ + +/* This tests whether GCC generates the ISA 3.1 BRW byte swap instruction for + GPR data, but generates XXBRW for data in a vector register. */ + +unsigned int +bswap_int (unsigned int a) +{ + return __builtin_bswap32 (a); /* { dg-final { scan-assembler {\mbrw\M} } } */ +} + +double +bswap_int_dbl (unsigned int a) +{ + unsigned int b = a; + /* Force the value to be loaded into a vector register. */ + __asm__ (" # %x0" : "+wa" (b)); + + /* { dg-final { scan-assembler {\mxxbrw\M} } } */ + return (double) __builtin_bswap32 (b); +}