Message ID | 20211229012740.3245971-1-luoxhu@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 378A23858404 for <patchwork@sourceware.org>; Wed, 29 Dec 2021 01:28:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 378A23858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1640741322; bh=ZeXt2SoDMobwvqSlxhb/87k/kPscpKFW2v7Hz1/LKpk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=rjoRxiOXIUutBvolv78ibhjNpnnuu+evplZmk7HGrMiXzKbra6yWOmojyVPMFO8Wi UwbLvokTOa4cskxCBPNmlI2kXJwVZn64wa6p9ZfS6GlZqx/IYKGnxfemujRVYY2pch r08vXhTCQZN55hhjxFJA2H4mZmp7dLkJV1JuAtgQ= 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 EC612385843F; Wed, 29 Dec 2021 01:27:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EC612385843F Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1BT0S18N024781; Wed, 29 Dec 2021 01:27:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3d7sk2qdqn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Dec 2021 01:27:49 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1BT1Rn02007419; Wed, 29 Dec 2021 01:27:49 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3d7sk2qdq7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Dec 2021 01:27:49 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1BT1McwF023042; Wed, 29 Dec 2021 01:27:47 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 3d5tjjkcp1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Dec 2021 01:27:46 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1BT1Rhjo41615640 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Dec 2021 01:27:43 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7DA624C040; Wed, 29 Dec 2021 01:27:43 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5DB774C04A; Wed, 29 Dec 2021 01:27:42 +0000 (GMT) Received: from rain6p1.aus.stglabs.ibm.com (unknown [9.40.203.151]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 29 Dec 2021 01:27:42 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] rs6000: Add split pattern to replace Date: Tue, 28 Dec 2021 19:27:40 -0600 Message-Id: <20211229012740.3245971-1-luoxhu@linux.ibm.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: HurV-h9L-dGDGwmtXH6ns-QF9VBwMw2s X-Proofpoint-GUID: xsNEm1d-xb6b0GkLHLNnACkCR4ddonYv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-28_13,2021-12-28_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 clxscore=1015 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112290003 X-Spam-Status: No, score=-10.7 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Xionghu Luo via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Xionghu Luo <luoxhu@linux.ibm.com> Cc: segher@kernel.crashing.org, Xionghu Luo <luoxhu@linux.ibm.com>, wschmidt@linux.ibm.com, linkw@gcc.gnu.org, dje.gcc@gmail.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
rs6000: Add split pattern to replace
|
|
Commit Message
Xionghu Luo
Dec. 29, 2021, 1:27 a.m. UTC
7: r120:V4SI=const_vector 8: r121:V4SI=unspec[r120:V4SI,r120:V4SI,0xc] 260 with r121:v4SI = r120:V4SI when r120 is a vector with same element. Bootstrapped and regtested pass on powerpc64le-linux-gnu {P10, P9} and powerpc64-linux-gnu {P8, P7}. OK for master? gcc/ChangeLog: * config/rs6000/altivec.md (sldoi_to_mov_<mode>): New. gcc/testsuite/ChangeLog: * gcc.target/powerpc/sldoi_to_mov.c: New test. --- gcc/config/rs6000/altivec.md | 11 +++++++++++ gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c | 15 +++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c
Comments
Gentle ping, thanks. On 2021/12/29 09:27, Xionghu Luo wrote: > 7: r120:V4SI=const_vector > 8: r121:V4SI=unspec[r120:V4SI,r120:V4SI,0xc] 260 > > with r121:v4SI = r120:V4SI when r120 is a vector with same element. > > Bootstrapped and regtested pass on powerpc64le-linux-gnu {P10, P9} > and powerpc64-linux-gnu {P8, P7}. OK for master? > > gcc/ChangeLog: > > * config/rs6000/altivec.md (sldoi_to_mov_<mode>): New. > > gcc/testsuite/ChangeLog: > > * gcc.target/powerpc/sldoi_to_mov.c: New test. > --- > gcc/config/rs6000/altivec.md | 11 +++++++++++ > gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c | 15 +++++++++++++++ > 2 files changed, 26 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c > > diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md > index b2909857c34..25f86dbe828 100644 > --- a/gcc/config/rs6000/altivec.md > +++ b/gcc/config/rs6000/altivec.md > @@ -383,6 +383,17 @@ (define_split > } > }) > > +(define_insn_and_split "sldoi_to_mov_<mode>" > + [(set (match_operand:VM 0 "altivec_register_operand") > + (unspec:VM [(match_operand:VM 1 "easy_vector_constant") > + (match_dup 1) > + (match_operand:VM 2 "u5bit_cint_operand")] > + UNSPEC_VSLDOI))] > + "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode) && can_create_pseudo_p ()" > + "#" > + "&& 1" > + [(set (match_dup 0) (match_dup 1))]) > + > (define_insn "get_vrsave_internal" > [(set (match_operand:SI 0 "register_operand" "=r") > (unspec:SI [(reg:SI VRSAVE_REGNO)] UNSPEC_GET_VRSAVE))] > diff --git a/gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c b/gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c > new file mode 100644 > index 00000000000..2053243c456 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c > @@ -0,0 +1,15 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +#include <altivec.h> > +vector signed int foo1 (vector signed int a) { > + vector signed int b = {0}; > + return vec_sum2s(a, b); > +} > + > +vector signed int foo2 (vector signed int a) { > + vector signed int b = {0}; > + return vec_sld(b, b, 4); > +} > + > +/* { dg-final { scan-assembler-times {\mvsldoi\M} 1 {target le} } } */
On Mon, Jan 10, 2022 at 12:04 AM Xionghu Luo <luoxhu@linux.ibm.com> wrote: > > Gentle ping, thanks. > > > On 2021/12/29 09:27, Xionghu Luo wrote: > > 7: r120:V4SI=const_vector > > 8: r121:V4SI=unspec[r120:V4SI,r120:V4SI,0xc] 260 > > > > with r121:v4SI = r120:V4SI when r120 is a vector with same element. > > > > Bootstrapped and regtested pass on powerpc64le-linux-gnu {P10, P9} > > and powerpc64-linux-gnu {P8, P7}. OK for master? > > > > gcc/ChangeLog: > > > > * config/rs6000/altivec.md (sldoi_to_mov_<mode>): New. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.target/powerpc/sldoi_to_mov.c: New test. > > --- > > gcc/config/rs6000/altivec.md | 11 +++++++++++ > > gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c | 15 +++++++++++++++ > > 2 files changed, 26 insertions(+) > > create mode 100644 gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c > > > > diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md > > index b2909857c34..25f86dbe828 100644 > > --- a/gcc/config/rs6000/altivec.md > > +++ b/gcc/config/rs6000/altivec.md > > @@ -383,6 +383,17 @@ (define_split > > } > > }) > > > > +(define_insn_and_split "sldoi_to_mov_<mode>" It would be more consistent with the naming convention to use "sldoi_to_mov<mode>" without the final "_". > > + [(set (match_operand:VM 0 "altivec_register_operand") > > + (unspec:VM [(match_operand:VM 1 "easy_vector_constant") Should this be "easy_vector_constant_vsldoi"? > > + (match_dup 1) > > + (match_operand:VM 2 "u5bit_cint_operand")] This should be match_operand:QI, right? Thanks, David > > + UNSPEC_VSLDOI))] > > + "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode) && can_create_pseudo_p ()" > > + "#" > > + "&& 1" > > + [(set (match_dup 0) (match_dup 1))]) > > + > > (define_insn "get_vrsave_internal" > > [(set (match_operand:SI 0 "register_operand" "=r") > > (unspec:SI [(reg:SI VRSAVE_REGNO)] UNSPEC_GET_VRSAVE))] > > diff --git a/gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c b/gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c > > new file mode 100644 > > index 00000000000..2053243c456 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c > > @@ -0,0 +1,15 @@ > > +/* { dg-do compile } */ > > +/* { dg-options "-O2" } */ > > + > > +#include <altivec.h> > > +vector signed int foo1 (vector signed int a) { > > + vector signed int b = {0}; > > + return vec_sum2s(a, b); > > +} > > + > > +vector signed int foo2 (vector signed int a) { > > + vector signed int b = {0}; > > + return vec_sld(b, b, 4); > > +} > > + > > +/* { dg-final { scan-assembler-times {\mvsldoi\M} 1 {target le} } } */ > > -- > Thanks, > Xionghu
On 2022/1/11 06:55, David Edelsohn wrote: >>> +(define_insn_and_split "sldoi_to_mov_<mode>" > It would be more consistent with the naming convention to use > "sldoi_to_mov<mode>" without the final "_". OK, thanks. > >>> + [(set (match_operand:VM 0 "altivec_register_operand") >>> + (unspec:VM [(match_operand:VM 1 "easy_vector_constant") > Should this be "easy_vector_constant_vsldoi"? This doesn't work. easy_vector_constant_vsldoi return false due to vspltis_shifted "return 0" as: vspltis_shifted (rtx op): /* If all elements are equal, we don't need to do VSLDOI. */ (gdb) p op $7 = (rtx_def *) (const_vector:V4SI [ (const_int 0 [0]) repeated x4 ]) (gdb) p easy_vector_constant_vsldoi(op, V4SImode) $8 = false p easy_vector_constant(op, V4SImode) $9 = true > >>> + (match_dup 1) >>> + (match_operand:VM 2 "u5bit_cint_operand")] > This should be match_operand:QI, right? Yes. > > Thanks, David >
On Tue, Jan 11, 2022 at 2:27 AM Xionghu Luo <luoxhu@linux.ibm.com> wrote: > > On 2022/1/11 06:55, David Edelsohn wrote: > >>> +(define_insn_and_split "sldoi_to_mov_<mode>" > > It would be more consistent with the naming convention to use > > "sldoi_to_mov<mode>" without the final "_". > > OK, thanks. > > > > >>> + [(set (match_operand:VM 0 "altivec_register_operand") > >>> + (unspec:VM [(match_operand:VM 1 "easy_vector_constant") > > Should this be "easy_vector_constant_vsldoi"? > > > This doesn't work. easy_vector_constant_vsldoi return false due to > vspltis_shifted "return 0" as: > > vspltis_shifted (rtx op): /* If all elements are equal, we don't need to do VSLDOI. */ > > > (gdb) p op > $7 = (rtx_def *) (const_vector:V4SI [ > (const_int 0 [0]) repeated x4 > ]) > (gdb) p easy_vector_constant_vsldoi(op, V4SImode) > $8 = false > p easy_vector_constant(op, V4SImode) > $9 = true Okay, thanks for checking. > > > > >>> + (match_dup 1) > >>> + (match_operand:VM 2 "u5bit_cint_operand")] > > This should be match_operand:QI, right? > > Yes. This patch is okay with the other changes. Thanks, David
diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md index b2909857c34..25f86dbe828 100644 --- a/gcc/config/rs6000/altivec.md +++ b/gcc/config/rs6000/altivec.md @@ -383,6 +383,17 @@ (define_split } }) +(define_insn_and_split "sldoi_to_mov_<mode>" + [(set (match_operand:VM 0 "altivec_register_operand") + (unspec:VM [(match_operand:VM 1 "easy_vector_constant") + (match_dup 1) + (match_operand:VM 2 "u5bit_cint_operand")] + UNSPEC_VSLDOI))] + "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode) && can_create_pseudo_p ()" + "#" + "&& 1" + [(set (match_dup 0) (match_dup 1))]) + (define_insn "get_vrsave_internal" [(set (match_operand:SI 0 "register_operand" "=r") (unspec:SI [(reg:SI VRSAVE_REGNO)] UNSPEC_GET_VRSAVE))] diff --git a/gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c b/gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c new file mode 100644 index 00000000000..2053243c456 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/sldoi_to_mov.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include <altivec.h> +vector signed int foo1 (vector signed int a) { + vector signed int b = {0}; + return vec_sum2s(a, b); +} + +vector signed int foo2 (vector signed int a) { + vector signed int b = {0}; + return vec_sld(b, b, 4); +} + +/* { dg-final { scan-assembler-times {\mvsldoi\M} 1 {target le} } } */