From patchwork Wed Jul 5 03:22:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HAO CHEN GUI X-Patchwork-Id: 115922 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1598921vqx; Tue, 4 Jul 2023 20:23:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlHpKlD/duSfc6gXfsB4DYahLwih+Nxm2HJxlbLTJGSu5+om8M+7UNbVDvCrdEPV9Ql7Qky1 X-Received: by 2002:a17:906:944e:b0:988:bb33:53a8 with SMTP id z14-20020a170906944e00b00988bb3353a8mr11154461ejx.9.1688527433495; Tue, 04 Jul 2023 20:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688527433; cv=none; d=google.com; s=arc-20160816; b=zZYuVloSSSyb6feZPAuu21ZCZBOfvwtoczvFd2wFSoiUeyh4L5Q/VmJ/xzQ6rUOxTh 7fREWSN2EM2BzTbVIoJVdDWmCgv/JNG0j0BQLlvguOyJklnUJV6R/zVHIhnpZOLeiCsQ aB5FCA7UUSeYc4tSYtJD/9qBmUGgYBN0th1xt44XAFwYC0Db+DWaHvJfF4IziMlztlON N4GMujJknORVP9KoNMFVT0ZaM3/rVvLgpSd7dkCjKthmwX8OXKZGjBcZsip4CiHOZt6d 14CQXcZyNHOKiKkxpe5wjzloLu/+VVjIGxDiPOywgD4JnSJ6H2wMPURtflS7kQ28K2Pt R7WA== 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:mime-version :content-transfer-encoding:subject:cc:to:content-language:user-agent :date:message-id:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=UhBIiEq0LcMQn/0G/dFVYh87gLWSyh7dAEW69lGD+g8=; fh=3eUSxJU+9IWNwGHlMjnmqDQDnJfeMKAjlglEUO7a4vw=; b=JrGQFSTOjjVy56t/1Iw2Ywl6uYkqKFOnX1V3w3qkQ5RmgiHnWPjYbyUKj2ZcK3XyRH rx3yAiFc8dZcrQZk3tcd45H/BeHXkHcfadOBZVVcqzKugTzpPOWVWGXkS3X0daGIWhZl GOGYQgO5dHLt6SbtnayaOfUljT3kFjKwCYBqBOvyQUzigdBr93DTRGUoIhf91jJJL5r1 lx6Sh6VwgW8kpzqbMjmbaEwjHMMPzSUt9ABfDxk4bXH8Q0y9QopI3KrQWWNB4KMNLklP d+nwgvqv7hXBBvrqiQR3vz970gYmKHKF1KbFR90JZOzXj+aFCxQ5Ra2dctMimaHkbR40 XkaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=K78IVI4X; 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 c25-20020a170906529900b009920ac37840si10380529ejm.403.2023.07.04.20.23.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 20:23:53 -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=K78IVI4X; 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 53A603857709 for ; Wed, 5 Jul 2023 03:23:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53A603857709 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688527432; bh=UhBIiEq0LcMQn/0G/dFVYh87gLWSyh7dAEW69lGD+g8=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=K78IVI4XPDrYXIrobEl2u3UCauMIPLumV3ndeoJpVLv7A8b5VJ8F7mSObK9GHHUOj nkMbraNf2cvlegUyD9GG+uON/KqiS1tgT5sfml7JqYalm3GJR1Edu8UGSVs+d99n1f FIQkWiXB3QzDFotqFRv5LCm+JmhrkBVqXYLmTfkg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id DE9523858D32 for ; Wed, 5 Jul 2023 03:23:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE9523858D32 Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3653Gl7G027537; Wed, 5 Jul 2023 03:23:07 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rn0fjr45u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jul 2023 03:23:07 +0000 Received: from m0353722.ppops.net (m0353722.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3653ImHm002540; Wed, 5 Jul 2023 03:23:06 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rn0fjr45b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jul 2023 03:23:06 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3653KYCr006559; Wed, 5 Jul 2023 03:23:04 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3rjbs4sqgt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jul 2023 03:23:04 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3653N1Fl24838626 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jul 2023 03:23:01 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1727A20043; Wed, 5 Jul 2023 03:23:01 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 90D7B20040; Wed, 5 Jul 2023 03:22:59 +0000 (GMT) Received: from [9.200.144.106] (unknown [9.200.144.106]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jul 2023 03:22:59 +0000 (GMT) Message-ID: <3222166e-8d56-246e-519a-08807917c6d8@linux.ibm.com> Date: Wed, 5 Jul 2023 11:22:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Content-Language: en-US To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner Subject: [PATCH, rs6000] Skip redundant vector extract if the element is first element of dword0 [PR110429] X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 0JFbS1sWlEGVQYcYln9f725fkKsTrO14 X-Proofpoint-ORIG-GUID: LM_AbhKdj0TDMGUC4k6eaLijSuTLES7C X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-04_16,2023-07-04_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 impostorscore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307050027 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, 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: HAO CHEN GUI via Gcc-patches From: HAO CHEN GUI Reply-To: HAO CHEN GUI 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?1770549342103754711?= X-GMAIL-MSGID: =?utf-8?q?1770549342103754711?= Hi, This patch skips redundant vector extract insn to be generated when the extracted element is the first element of dword0 and the destination is a memory operand. Only one 'stxsi[hb]x' instruction is enough. The V4SImode is fixed in a previous patch. https://gcc.gnu.org/pipermail/gcc-patches/2023-June/622101.html Bootstrapped and tested on powerpc64-linux BE and LE with no regressions. Thanks Gui Haochen ChangeLog rs6000: Skip redundant vector extract if the element is first element of dword0 gcc/ PR target/110429 * config/rs6000/vsx.md (*vsx_extract__store_p9): Skip vector extract when the element is the first element of dword0. gcc/testsuite/ PR target/110429 * gcc.target/powerpc/pr110429.c: New. patch.diff diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index 0c269e4e8d9..b3fec910eb6 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -3855,7 +3855,22 @@ (define_insn_and_split "*vsx_extract__store_p9" (parallel [(match_dup 2)]))) (clobber (match_dup 4))]) (set (match_dup 0) - (match_dup 3))]) + (match_dup 3))] +{ + enum machine_mode dest_mode = GET_MODE (operands[0]); + + if (which_alternative == 0 + && ((mode == V16QImode + && INTVAL (operands[2]) == (BYTES_BIG_ENDIAN ? 7 : 8)) + || (mode == V8HImode + && INTVAL (operands[2]) == (BYTES_BIG_ENDIAN ? 3 : 4)))) + { + emit_move_insn (operands[0], + gen_rtx_REG (dest_mode, REGNO (operands[3]))); + DONE; + } +}) + (define_insn_and_split "*vsx_extract_si" [(set (match_operand:SI 0 "nonimmediate_operand" "=r,wa,Z") diff --git a/gcc/testsuite/gcc.target/powerpc/pr110429.c b/gcc/testsuite/gcc.target/powerpc/pr110429.c new file mode 100644 index 00000000000..5a938f9f90a --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr110429.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } } */ +/* { dg-require-effective-target powerpc_p9vector_ok } */ +/* { dg-options "-mdejagnu-cpu=power9 -O2" } */ +/* { dg-require-effective-target has_arch_ppc64 } */ + +#include + +#ifdef __BIG_ENDIAN__ +#define DWORD0_FIRST_SHORT 3 +#define DWORD0_FIRST_CHAR 7 +#else +#define DWORD0_FIRST_SHORT 4 +#define DWORD0_FIRST_CHAR 8 +#endif + +void vec_extract_short (vector short v, short* p) +{ + *p = vec_extract(v, DWORD0_FIRST_SHORT); +} + +void vec_extract_char (vector char v, char* p) +{ + *p = vec_extract(v, DWORD0_FIRST_CHAR); +} + +/* { dg-final { scan-assembler-times "stxsi\[hb\]x" 2 } } */ +/* { dg-final { scan-assembler-not "vextractu\[hb\]" } } */