From patchwork Wed Nov 25 13:32:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Krebbel X-Patchwork-Id: 548568 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5A0561402E2 for ; Thu, 26 Nov 2015 00:33:43 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=a8boxTPq; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id; q=dns; s=default; b=aGNurtfqicQS/LJ OIKCyea0bSKaDBbmrwohZw1TsFfCM5VRabJNv6AyH6GXVwM9TgRo+RncC5su7Usu 2oeYCpmPKGvJmPcgLQ8psWI5RMmufYyhe+4owVfSTeC9EA5v4LkBfbQM+cVcNUb2 gReSdB9BFRkZqbbR19i8cfHOv9hM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id; s=default; bh=xUYlNN4LufLeyK9f+Rhvh mzvqx0=; b=a8boxTPqsh1eqXM0viZ5vqVzAfzlA485bNJUTlNM5PbkhKlFI4qyS DWkatobJ2jADoxF9wFeCIO1KpXqpnhXQEuzt2ZvPJgEUUey43vuiz8zvVyfxyXQR 63PxuGmg/FqvFZIIn0qVKrSGyHik/iN0/Ca9J2uM5bDJ39R2aaCfEo= Received: (qmail 63343 invoked by alias); 25 Nov 2015 13:33:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 63259 invoked by uid 89); 25 Nov 2015 13:33:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: e06smtp14.uk.ibm.com Received: from e06smtp14.uk.ibm.com (HELO e06smtp14.uk.ibm.com) (195.75.94.110) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 25 Nov 2015 13:33:01 +0000 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Nov 2015 13:32:58 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 25 Nov 2015 13:32:57 -0000 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: krebbel@linux.vnet.ibm.com X-IBM-RcptTo: gcc-patches@gcc.gnu.org Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 847781B0805F for ; Wed, 25 Nov 2015 13:33:19 +0000 (GMT) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tAPDWupY66191392 for ; Wed, 25 Nov 2015 13:32:56 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tAPDWuUb015100 for ; Wed, 25 Nov 2015 06:32:56 -0700 Received: from maggie.boeblingen.de.ibm.com (dyn-9-152-212-123.boeblingen.de.ibm.com [9.152.212.123]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tAPDWtcu015085 (version=TLSv1/SSLv3 cipher=AES256-SHA256 bits=256 verify=NO) for ; Wed, 25 Nov 2015 06:32:56 -0700 From: Andreas Krebbel To: gcc-patches@gcc.gnu.org Subject: [PATCH] S/390: Further bswap enhancements. Date: Wed, 25 Nov 2015 14:32:52 +0100 Message-Id: <1448458375-6489-1-git-send-email-krebbel@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15112513-0017-0000-0000-00000650DDC0 X-IsSubscribed: yes This adds support for the store reverse instructions. It also implements a splitter making use of 32 bit load reverse register to implement bswaphi reg-reg. gcc/ChangeLog: 2015-11-25 Andreas Krebbel * config/s390/s390.md ("bswap2"): Add support for strv and strvg. ("bswaphi2"): New pattern. New splitter for HI reg-reg bswap. gcc/testsuite/ChangeLog: 2015-11-25 Andreas Krebbel * gcc.target/s390/bswap-1.c (foo64c, foo32a, foo32c): New functions. * gcc.target/s390/bswaphi-1.c: New test. --- gcc/config/s390/s390.md | 38 +++++++++++++++++++++++-------- gcc/testsuite/gcc.target/s390/bswap-1.c | 26 +++++++++++++++++---- gcc/testsuite/gcc.target/s390/bswaphi-1.c | 27 ++++++++++++++++++++++ 3 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/bswaphi-1.c diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index a5335ca..e5db537 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -10451,25 +10451,43 @@ ; FIXME: There is also mvcin but we cannot use it since src and target ; may overlap. (define_insn "bswap2" - [(set (match_operand:GPR 0 "register_operand" "=d, d") - (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,RT")))] + [(set (match_operand:GPR 0 "nonimmediate_operand" "=d, d,RT") + (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,RT, d")))] "TARGET_CPU_ZARCH" "@ lrvr\t%0,%1 - lrv\t%0,%1" - [(set_attr "type" "*,load") - (set_attr "op_type" "RRE,RXY") + lrv\t%0,%1 + strv\t%1,%0" + [(set_attr "type" "*,load,store") + (set_attr "op_type" "RRE,RXY,RXY") (set_attr "z10prop" "z10_super")]) (define_insn "bswaphi2" - [(set (match_operand:HI 0 "register_operand" "=d") - (bswap:HI (match_operand:HI 1 "memory_operand" "RT")))] + [(set (match_operand:HI 0 "nonimmediate_operand" "=d, d,RT") + (bswap:HI (match_operand:HI 1 "nonimmediate_operand" " d,RT, d")))] "TARGET_CPU_ZARCH" - "lrvh\t%0,%1" - [(set_attr "type" "load") - (set_attr "op_type" "RXY") + "@ + # + lrvh\t%0,%1 + strvh\t%1,%0" + [(set_attr "type" "*,load,store") + (set_attr "op_type" "RRE,RXY,RXY") (set_attr "z10prop" "z10_super")]) +(define_split + [(set (match_operand:HI 0 "register_operand" "") + (bswap:HI (match_operand:HI 1 "register_operand" "")))] + "TARGET_CPU_ZARCH" + [(set (match_dup 2) (bswap:SI (match_dup 3))) + (set (match_dup 2) (lshiftrt:SI (match_dup 2) + (const_int 16))) + (set (match_dup 0) (subreg:HI (match_dup 2) 2))] +{ + operands[2] = gen_reg_rtx (SImode); + operands[3] = simplify_gen_subreg (SImode, operands[1], HImode, 0); +}) + + ; ; Population count instruction ; diff --git a/gcc/testsuite/gcc.target/s390/bswap-1.c b/gcc/testsuite/gcc.target/s390/bswap-1.c index e1f113a..edfcdf8 100644 --- a/gcc/testsuite/gcc.target/s390/bswap-1.c +++ b/gcc/testsuite/gcc.target/s390/bswap-1.c @@ -21,16 +21,32 @@ foo64b () } /* { dg-final { scan-assembler-times "lrvg\t%r2,0\\(%r\[0-9\]*\\)" 1 { target lp64 } } } */ +void +foo64c (uint64_t a) +{ + u64 = __builtin_bswap64 (a); +} +/* { dg-final { scan-assembler-times "strvg\t%r2,0\\(%r\[0-9\]*\\)" 1 { target lp64 } } } */ + + + +uint32_t +foo32a (uint32_t a) +{ + return __builtin_bswap32 (a); +} +/* { dg-final { scan-assembler-times "lrvr\t%r2,%r2" 1 } } */ + uint32_t -foo32 () +foo32b () { return __builtin_bswap32 (u32); } /* { dg-final { scan-assembler-times "lrv\t%r2,0\\(%r\[0-9\]*\\)" 1 } } */ -uint16_t -foo16 () +void +foo32c (uint32_t a) { - return __builtin_bswap16 (u16); + u32 = __builtin_bswap32 (a); } -/* { dg-final { scan-assembler-times "lrvh\t%r2,0\\(%r\[0-9\]*\\)" 1 } } */ +/* { dg-final { scan-assembler-times "strv\t%r2,0\\(%r\[0-9\]*\\)" 1 } } */ diff --git a/gcc/testsuite/gcc.target/s390/bswaphi-1.c b/gcc/testsuite/gcc.target/s390/bswaphi-1.c new file mode 100644 index 0000000..f6be9b4 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/bswaphi-1.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -march=z900 -mzarch" } */ + +#include + +uint16_t u16; + +uint16_t +foo16a (uint16_t a) +{ + return __builtin_bswap16 (a); +} +/* { dg-final { scan-assembler-times "lrvr\t%r2,%r\[0-9\]*" 1 } } */ + +uint16_t +foo16b () +{ + return __builtin_bswap16 (u16); +} +/* { dg-final { scan-assembler-times "lrvh\t%r2,0\\(%r\[0-9\]*\\)" 1 } } */ + +void +foo16c (uint16_t a) +{ + u16 = __builtin_bswap16 (a); +} +/* { dg-final { scan-assembler-times "strvh\t%r2,0\\(%r\[0-9\]*\\)" 1 } } */