From patchwork Tue Oct 11 07:38:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HAO CHEN GUI X-Patchwork-Id: 1907 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1961073wrs; Tue, 11 Oct 2022 00:39:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6grx4+X5hty6//3uoObq6ORWlwcILFxTOIJGKeP1TV8N4Jzn8LyYagS8wyYk/rNYrWdgRV X-Received: by 2002:a17:906:4786:b0:78d:c3c0:1508 with SMTP id cw6-20020a170906478600b0078dc3c01508mr4616000ejc.211.1665473985638; Tue, 11 Oct 2022 00:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665473985; cv=none; d=google.com; s=arc-20160816; b=OGSopEkGM38rmozFXXyR9IWrzUzBIuj+Qxv99Z5Sgy5H3BMLDbrsRF6np392WFpO0c vdDAXReCDmnIengv0HQc31374mTVTquDuKw4KgNKXz/G2t4r+KO3sgJjeGttNAXi6RIX WNTCHZp2opo7VRp3HMaoIdohSQTA0+q715uv/3uAQZTMbJ8qdx6fnM8lQB8m/Dm9UCV6 5IagYxk4yMx8VRlE69dj7Vu7Ieh0r0sLdxxCw9bB7152mbtWcAMc64VuGIlk9tHsQCEg YLe56lU0SpjnAgY9DoO3dbF1oVvrKUaTdqOUltdrp5gQj2cPJYO8PV8Ut2XcG0QX9Mhp yYGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:subject:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=Xe3EbdUH3msqwR2laBbOnttRmsaAkUZT7ho1h9K8NcY=; b=nfdYz4RRkARwZBO2Tlr4ySuV32mWKmV+Dmc0MyrwbRhIXStcc5C3Xb4rXVPLBvxSIs j+fPE7w02cjfW/m36qTHVHW1FU8fDwiSkI5koEYGSWRI2wgd79RXBsqAiItpUCcjvjcM ktPOshVBfjYFkU/JMQuqhIZ6/s+qAhpb5Smp+LMrHygvSBpkSS/r82QccvHlE5z7fsZZ WITasYOrFgw/tca8GR1IF8mLB3xRlHuoC/pDRjGD/Q5IMnZK4aTLHI+/viBJDpxMrOYp T0tDW53Bso2rnYc4wYEx0UeuVlMIiIzv4wZKVw1ZYkeubiDe6sTmtvZ1xJm1UiP/b/O7 kgjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=KfHUrWFh; 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 sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id x19-20020a1709064bd300b007829f6fed9dsi12505134ejv.232.2022.10.11.00.39.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 00:39:45 -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=KfHUrWFh; 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 7A38B3857004 for ; Tue, 11 Oct 2022 07:39:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A38B3857004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665473984; bh=Xe3EbdUH3msqwR2laBbOnttRmsaAkUZT7ho1h9K8NcY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=KfHUrWFhP1KnEK7ogG4PnmeAA7Q97jeShH/mvngQ95o9yPaYnxHigbEA49lw1HUFK /mdmCTQqWKY3Z5uIlDDwnHXmZMJeggkZpD9laQVN420xMEJu2tly+NubnRj6sKcnjm BEyDKGUDHg4jiwJi92/rX+sYPtPdqxVXdmo+x7o8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id EA1C53857B99 for ; Tue, 11 Oct 2022 07:38:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA1C53857B99 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29B640JE000439; Tue, 11 Oct 2022 07:38:58 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k4ux0keb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Oct 2022 07:38:57 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29B6aaDd023732; Tue, 11 Oct 2022 07:38:57 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k4ux0kea4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Oct 2022 07:38:57 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29B7Yu78025098; Tue, 11 Oct 2022 07:38:54 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3k30u93vcn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 11 Oct 2022 07:38:54 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29B7cpeO57213340 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 11 Oct 2022 07:38:51 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 494A552050; Tue, 11 Oct 2022 07:38:51 +0000 (GMT) Received: from [9.197.244.233] (unknown [9.197.244.233]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 7A8B65204F; Tue, 11 Oct 2022 07:38:49 +0000 (GMT) Message-ID: Date: Tue, 11 Oct 2022 15:38:48 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Content-Language: en-US To: gcc-patches Subject: [PATCH-1, rs6000] Generate permute index directly for little endian target [PR100866] X-TM-AS-GCONF: 00 X-Proofpoint-GUID: -GZaDM35ily6VQmIkVwOrCFB9171uqpY X-Proofpoint-ORIG-GUID: ESszF9uXXtJ_9j-6XFdbPUQttSvfJhpe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-10-11_03,2022-10-10_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 impostorscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210110041 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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: HAO CHEN GUI via Gcc-patches From: HAO CHEN GUI Reply-To: HAO CHEN GUI Cc: Peter Bergner , David , Segher Boessenkool 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?1746376050083693264?= X-GMAIL-MSGID: =?utf-8?q?1746376050083693264?= Hi, This patch modifies the help function which generates permute index for vector byte reversion and generates permute index directly for little endian targets. It saves one "xxlnor" instructions on P8 little endian targets as the original process needs an "xxlnor" to calculate complement for the index. Bootstrapped and tested on ppc64 Linux BE and LE with no regressions. Is this okay for trunk? Any recommendations? Thanks a lot. ChangeLog 2022-10-11 Haochen Gui gcc/ PR target/100866 * config/rs6000/rs6000-call.cc (swap_endian_selector_for_mode): Generate permute index directly for little endian targets. * config/rs6000/vsx.md (revb_): Call vprem directly with corresponding permute indexes. gcc/testsuite/ PR target/100866 * gcc.target/powerpc/pr100866.c: New. patch.diff diff --git a/gcc/config/rs6000/rs6000-call.cc b/gcc/config/rs6000/rs6000-call.cc index 551968b0995..bad8e9e0e52 100644 --- a/gcc/config/rs6000/rs6000-call.cc +++ b/gcc/config/rs6000/rs6000-call.cc @@ -2839,7 +2839,10 @@ swap_endian_selector_for_mode (machine_mode mode) } for (i = 0; i < 16; ++i) - perm[i] = GEN_INT (swaparray[i]); + if (BYTES_BIG_ENDIAN) + perm[i] = GEN_INT (swaparray[i]); + else + perm[i] = GEN_INT (~swaparray[i] & 0x0000001f); return force_reg (V16QImode, gen_rtx_CONST_VECTOR (V16QImode, gen_rtvec_v (16, perm))); diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index e226a93bbe5..b68eba48d2c 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -6096,8 +6096,8 @@ (define_expand "revb_" to the endian mode in use, i.e. in LE mode, put elements in BE order. */ rtx sel = swap_endian_selector_for_mode(mode); - emit_insn (gen_altivec_vperm_ (operands[0], operands[1], - operands[1], sel)); + emit_insn (gen_altivec_vperm__direct (operands[0], operands[1], + operands[1], sel)); } DONE; diff --git a/gcc/testsuite/gcc.target/powerpc/pr100866.c b/gcc/testsuite/gcc.target/powerpc/pr100866.c new file mode 100644 index 00000000000..c708dfd502e --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr100866.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power8" } */ +/* { dg-final { scan-assembler-not "xxlnor" } } */ + +#include + +vector unsigned short revb(vector unsigned short a) +{ + return vec_revb(a); +}