From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 56DD23858D33 for ; Fri, 28 Jul 2023 09:32:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 56DD23858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36S9ECsU012964; Fri, 28 Jul 2023 09:32:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : from : subject : to : cc : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=t9db7RskagJ+5syu4vcM57Q9TjyvPmYVSH7givRcg60=; b=BPCZPsNZi3YX8hbbKIFFnfawcj6lRE0JXviJ0QSKD5Nm+8wtwFpVFXn9zetXHdCPQ/jC V5/cX1eh4alFf07gOUCQe+cMxyvp3M8kTrZkBXB/CJUAcFO/JUyGFm9v37X21/ugLVkA SK8EhmA0k7PSvZg5l8oiN1VIXdv8fBF7KjTZFL1dy3H0uB36BKr82qPKlyXSM5NLwwu4 Vp1S7yGYSzi2UZUi+fIkxZ7fCarmXzqUUmzxqeV7EyddRigml3AC8GDptXI+hAzqbSTb Vbvs+ZYC6KKPYya+/9b8vvYSyyx1RjNS4NykGWnXND4OxYdrE+RDa9YelVwaYQztnnLw wA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s4av28f5b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jul 2023 09:32:18 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36S9WIgL013952; Fri, 28 Jul 2023 09:32:18 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3s4av28f50-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jul 2023 09:32:18 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36S790xA003624; Fri, 28 Jul 2023 09:32:17 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3s0txkmqus-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Jul 2023 09:32:17 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36S9WC6E20710000 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Jul 2023 09:32:14 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A44BA20074; Fri, 28 Jul 2023 09:32:12 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E08720040; Fri, 28 Jul 2023 09:32:10 +0000 (GMT) Received: from [9.177.64.55] (unknown [9.177.64.55]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 28 Jul 2023 09:32:10 +0000 (GMT) Message-ID: <98881646-a995-23ad-995e-f481a586f426@linux.ibm.com> Date: Fri, 28 Jul 2023 17:32:08 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 From: "Kewen.Lin" Subject: Re: [PATCH, rs6000] Skip redundant vector extract if the element is first element of dword0 [PR110429] To: HAO CHEN GUI Cc: Segher Boessenkool , David , Peter Bergner , gcc-patches References: <3222166e-8d56-246e-519a-08807917c6d8@linux.ibm.com> Content-Language: en-US In-Reply-To: <3222166e-8d56-246e-519a-08807917c6d8@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _y2MzcIUv2HJB7XRqGUfw-gUIKuCfhy7 X-Proofpoint-GUID: bqrXbDnbB545ZanEGkli8aI8Bvcu2j14 Content-Transfer-Encoding: 7bit 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-27_10,2023-07-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 clxscore=1015 adultscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307280082 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,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 List-Id: Hi Haochen, on 2023/7/5 11:22, HAO CHEN GUI wrote: > Hi, > This patch skips redundant vector extract insn to be generated when > the extracted element is the first element of dword0 and the destination "The first element" is confusing, it's easy to be misunderstood as element 0, but in fact the extracted element index is: - for byte, 7 on BE while 8 on LE; - for half word, 3 on BE while 4 on LE; so maybe just say when the extracted index for byte and half word like above, the element to be stored is already in the corresponding place for stxsi[hb]x, we don't need a redundant vector extraction at all. > 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]); Nit: Move this line ... > + > + if (which_alternative == 0 > + && ((mode == V16QImode > + && INTVAL (operands[2]) == (BYTES_BIG_ENDIAN ? 7 : 8)) > + || (mode == V8HImode > + && INTVAL (operands[2]) == (BYTES_BIG_ENDIAN ? 3 : 4)))) > + { ... here. > + 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 } } */ Nit: Break this check into stxsihx and stxsibx, and surround with \m and \M. > +/* { dg-final { scan-assembler-not "vextractu\[hb\]" } } */ Also with \m and \M. OK for trunk with these nits tweaked and testing goes well, thanks! BR, Kewen