Message ID | CAAgBjM=5ELyC+e3McMiaS--hiaR1yqxzKqvT3466XGBQjC_jig@mail.gmail.com |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:20da:b0:2d3:3019:e567 with SMTP id n26csp127618pxc; Fri, 5 Aug 2022 04:33:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR7lKZUWARoqEwvnYjEYY/hKGXD3Sw+Vz+1Uo9w4wOV3KX599ScpIZInimnJIF6TSFs8RwqU X-Received: by 2002:a17:907:1b0e:b0:72f:9b43:b98c with SMTP id mp14-20020a1709071b0e00b0072f9b43b98cmr4945722ejc.710.1659699225268; Fri, 05 Aug 2022 04:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659699225; cv=none; d=google.com; s=arc-20160816; b=kKwC0aywSyVwxs+OoOyP0xt+vMkxxzikn7wxzBPI85nw1PIJR7GAxRENrCUIhRlGWZ VDvMLWgxV25ZeCgkkgINZg5tn80hycJQQ9C/P6ubS4x6BibCrtMxmyih7nlxOOZSogGI Fy8LTTlTFZRK1muQgD+qZvrsUrTONA6zzwUiSqoDgBcafxiyIqLlfpZ3U6Egg3b1wrOT ZyZcukutmklMKXWxXSD5IhvmU7RyUu6Efb0n1aYDrGca5Br5DW1EVEE8Du9zOIzAE+tL 3XjjzkbiEx+BjI9ZUrO6nBTol399N0l4UlLaFlgf/DTixhp94BUaLxcywIRON0qzhjRH JgmA== 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:to:subject :message-id:date:mime-version:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=E9lA5lN2kPUsl9wVH47l+YvpUhxiFdKyCAjuQSOMhk0=; b=j9uwp5J/4c36KQcgYRV8CaeJUG2cZ152QanyYn1ryC4gjgY05lQBjlBFaViH3W+X/t lRmkaxokE6YswWEZZ5Rb07CzbP2J9Cuy58JxPk0mReu8nv62FeFICTk2YradwIuYpJB8 iFeSUgMp+oPOI9DSPSgQKXXE4maOVFWfcD5inBe5Tge10NfmOSMNFg48/QpVEHEJvOgj 9IIJudnysq6n096qbe2KFmpMmPpVbH/vVcrprt4sQ5kccqVLy1Yja1AOAJ9r9YaBaX0H a+W/yIuugXR2l83/eA3YbJT2HiRR7oNA7pyOMNExPz44dnc3CzjgTgHXO4xp6/T1/ORQ b1FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="AVA/POjd"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o15-20020a170906974f00b00710e9e0a239si3976751ejy.919.2022.08.05.04.33.44 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 04:33:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="AVA/POjd"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 CBC1C3857355 for <ouuuleilei@gmail.com>; Fri, 5 Aug 2022 11:33:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBC1C3857355 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659699223; bh=E9lA5lN2kPUsl9wVH47l+YvpUhxiFdKyCAjuQSOMhk0=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=AVA/POjdW9Qak4SbuOThvK0B2L5YCBZh3gGA2erb8tw0ayE6dcP6ejZbaLoOqlGqR RHGh/rkzKtEF8KqX2JzSK0Qhzv7lzPIR1tYoWPsX3hEqajeKfRbz036+KXW1knbfN5 +9xRHRwPjxoNLd3Q/MY4DrLxhXSYhum2mamiXQxo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id C495B3858C53 for <gcc-patches@gcc.gnu.org>; Fri, 5 Aug 2022 11:32:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C495B3858C53 Received: by mail-ed1-x532.google.com with SMTP id e13so2962906edj.12 for <gcc-patches@gcc.gnu.org>; Fri, 05 Aug 2022 04:32:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=E9lA5lN2kPUsl9wVH47l+YvpUhxiFdKyCAjuQSOMhk0=; b=OZZVhB4cQGE4Sjw++2iB3hswTO2ZvO6JMmUc+sbEjzVYJPUr0CvO3qpmmfw8kkQTh7 tODvLZqyYsI/H1sS9EgDm3K+cEjk9bR8K4ggpyKKnWuSOnSFLWVDcoW5DZxxA7uiZJ4Y GW3oiFZFeVlDVeEsl8PghZkgRM3E7rMX5rrR3tdvxGmcHkg/UB/PpXZjwpdlsxJ2oRTr aF6+x5gmM1tR4j7cdJtZDeOESBpzG/MeGq8+M/p3QknKFBNxmb/uzOGkSEUlOQ8ocfjM kgIZPcfMhy8ovQfxiABKt/w04V6pOkaCusCXrgor89BILo0e8D2FtO1RIVLIUf/M7AtT K4JQ== X-Gm-Message-State: ACgBeo1W/GMv4VMjhgwsWBrpS4wK5F4pcfIm6fJrR2GhB4cEu8Pcinc6 AqfLYu+iD5uPiqqYPlqEW/SdZsPI1Xf8YPAXOeWVkg== X-Received: by 2002:a05:6402:40ce:b0:43d:f8a0:9c4f with SMTP id z14-20020a05640240ce00b0043df8a09c4fmr6301580edb.95.1659699178524; Fri, 05 Aug 2022 04:32:58 -0700 (PDT) MIME-Version: 1.0 Date: Fri, 5 Aug 2022 17:02:22 +0530 Message-ID: <CAAgBjM=5ELyC+e3McMiaS--hiaR1yqxzKqvT3466XGBQjC_jig@mail.gmail.com> Subject: Missed lowering to ld1rq from svld1rq for memory operand To: Richard Sandiford <richard.sandiford@arm.com>, gcc Patches <gcc-patches@gcc.gnu.org> Content-Type: multipart/mixed; boundary="000000000000f8b5af05e57cd3cd" X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, 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 <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: Prathamesh Kulkarni via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740320774992827505?= X-GMAIL-MSGID: =?utf-8?q?1740320774992827505?= |
Series |
Missed lowering to ld1rq from svld1rq for memory operand
|
|
Commit Message
Prathamesh Kulkarni
Aug. 5, 2022, 11:32 a.m. UTC
Hi Richard, Following from off-list discussion, in the attached patch, I wrote pattern similar to vec_duplicate<mode>_reg, which seems to work for the svld1rq tests. Does it look OK ? Sorry, I didn't fully understand your suggestion on integrating with vec_duplicate<mode>_reg pattern. For vec_duplicate<mode>_reg, the operand to vec_duplicate expects mode to be <VEL>, while the pattern in patch expects operand of vec_duplicate to have mode <V128>. How do we write a pattern so an operand can accept either of the 2 modes ? Also it seems <V128> cannot be used with SVE_ALL ? Thanks, Prathamesh
Comments
Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> writes: > Hi Richard, > Following from off-list discussion, in the attached patch, I wrote pattern > similar to vec_duplicate<mode>_reg, which seems to work for the svld1rq tests. > Does it look OK ? > > Sorry, I didn't fully understand your suggestion on integrating with > vec_duplicate<mode>_reg > pattern. For vec_duplicate<mode>_reg, the operand to vec_duplicate expects > mode to be <VEL>, while the pattern in patch expects operand of > vec_duplicate to have mode <V128>. > How do we write a pattern so an operand can accept either of the 2 modes ? I quoted the wrong one, sorry, should have been aarch64_vec_duplicate_vq<mode>_le. > Also it seems <V128> cannot be used with SVE_ALL ? Yeah, these would be SVE_FULL only. Richard
On Fri, 5 Aug 2022 at 17:49, Richard Sandiford <richard.sandiford@arm.com> wrote: > > Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> writes: > > Hi Richard, > > Following from off-list discussion, in the attached patch, I wrote pattern > > similar to vec_duplicate<mode>_reg, which seems to work for the svld1rq tests. > > Does it look OK ? > > > > Sorry, I didn't fully understand your suggestion on integrating with > > vec_duplicate<mode>_reg > > pattern. For vec_duplicate<mode>_reg, the operand to vec_duplicate expects > > mode to be <VEL>, while the pattern in patch expects operand of > > vec_duplicate to have mode <V128>. > > How do we write a pattern so an operand can accept either of the 2 modes ? > > I quoted the wrong one, sorry, should have been > aarch64_vec_duplicate_vq<mode>_le. > > > Also it seems <V128> cannot be used with SVE_ALL ? > > Yeah, these would be SVE_FULL only. Hi Richard, Sorry for the very late reply. I have attached patch, to integrate with vec_duplicate_vq<mode>_le. Bootstrapped+tested on aarch64-linux-gnu. OK to commit ? Thanks, Prathamesh > > Richard > gcc/ * config/aarch64/aarch64-sve.md (aarch64_vec_duplicate_vq<mode>_le): Change to define_insn_and_split to fold ldr+dup to ld1rq. * config/aarch64/predicates.md (aarch64_sve_dup_ld1rq_operand): New. testsuite/ * gcc.target/aarch64/sve/acle/general/pr96463-2.c: Adjust. diff --git a/gcc/config/aarch64/aarch64-sve.md b/gcc/config/aarch64/aarch64-sve.md index b8cc47ef5fc..4548375b8d6 100644 --- a/gcc/config/aarch64/aarch64-sve.md +++ b/gcc/config/aarch64/aarch64-sve.md @@ -2533,14 +2533,34 @@ ) ;; Duplicate an Advanced SIMD vector to fill an SVE vector (LE version). -(define_insn "@aarch64_vec_duplicate_vq<mode>_le" - [(set (match_operand:SVE_FULL 0 "register_operand" "=w") + +(define_insn_and_split "@aarch64_vec_duplicate_vq<mode>_le" + [(set (match_operand:SVE_FULL 0 "register_operand" "=w, w") (vec_duplicate:SVE_FULL - (match_operand:<V128> 1 "register_operand" "w")))] + (match_operand:<V128> 1 "aarch64_sve_dup_ld1rq_operand" "w, UtQ"))) + (clobber (match_scratch:VNx16BI 2 "=X, Upl"))] "TARGET_SVE && !BYTES_BIG_ENDIAN" { - operands[1] = gen_rtx_REG (<MODE>mode, REGNO (operands[1])); - return "dup\t%0.q, %1.q[0]"; + switch (which_alternative) + { + case 0: + operands[1] = gen_rtx_REG (<MODE>mode, REGNO (operands[1])); + return "dup\t%0.q, %1.q[0]"; + case 1: + return "#"; + default: + gcc_unreachable (); + } + } + "&& MEM_P (operands[1])" + [(const_int 0)] + { + if (GET_CODE (operands[2]) == SCRATCH) + operands[2] = gen_reg_rtx (VNx16BImode); + emit_move_insn (operands[2], CONSTM1_RTX (VNx16BImode)); + rtx gp = gen_lowpart (<VPRED>mode, operands[2]); + emit_insn (gen_aarch64_sve_ld1rq<mode> (operands[0], operands[1], gp)); + DONE; } ) diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md index ff7f73d3f30..6062f37025e 100644 --- a/gcc/config/aarch64/predicates.md +++ b/gcc/config/aarch64/predicates.md @@ -676,6 +676,10 @@ (ior (match_operand 0 "register_operand") (match_operand 0 "aarch64_sve_ld1r_operand"))) +(define_predicate "aarch64_sve_dup_ld1rq_operand" + (ior (match_operand 0 "register_operand") + (match_operand 0 "aarch64_sve_ld1rq_operand"))) + (define_predicate "aarch64_sve_ptrue_svpattern_immediate" (and (match_code "const") (match_test "aarch64_sve_ptrue_svpattern_p (op, NULL)"))) diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c index 196de3f5e0a..c38204e6874 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c @@ -26,4 +26,4 @@ TEST(svfloat64_t, float64_t, f64) TEST(svbfloat16_t, bfloat16_t, bf16) -/* { dg-final { scan-assembler-times {\tdup\tz[0-9]+\.q, z[0-9]+\.q\[0\]} 12 { target aarch64_little_endian } } } */ +/* { dg-final { scan-assembler-not {\tdup\t} } } */
Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> writes: > On Fri, 5 Aug 2022 at 17:49, Richard Sandiford > <richard.sandiford@arm.com> wrote: >> >> Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> writes: >> > Hi Richard, >> > Following from off-list discussion, in the attached patch, I wrote pattern >> > similar to vec_duplicate<mode>_reg, which seems to work for the svld1rq tests. >> > Does it look OK ? >> > >> > Sorry, I didn't fully understand your suggestion on integrating with >> > vec_duplicate<mode>_reg >> > pattern. For vec_duplicate<mode>_reg, the operand to vec_duplicate expects >> > mode to be <VEL>, while the pattern in patch expects operand of >> > vec_duplicate to have mode <V128>. >> > How do we write a pattern so an operand can accept either of the 2 modes ? >> >> I quoted the wrong one, sorry, should have been >> aarch64_vec_duplicate_vq<mode>_le. >> >> > Also it seems <V128> cannot be used with SVE_ALL ? >> >> Yeah, these would be SVE_FULL only. > Hi Richard, > Sorry for the very late reply. I have attached patch, to integrate > with vec_duplicate_vq<mode>_le. > Bootstrapped+tested on aarch64-linux-gnu. > OK to commit ? > > Thanks, > Prathamesh >> >> Richard >> > > gcc/ > * config/aarch64/aarch64-sve.md (aarch64_vec_duplicate_vq<mode>_le): > Change to define_insn_and_split to fold ldr+dup to ld1rq. > * config/aarch64/predicates.md (aarch64_sve_dup_ld1rq_operand): New. > > testsuite/ > * gcc.target/aarch64/sve/acle/general/pr96463-2.c: Adjust. > > diff --git a/gcc/config/aarch64/aarch64-sve.md b/gcc/config/aarch64/aarch64-sve.md > index b8cc47ef5fc..4548375b8d6 100644 > --- a/gcc/config/aarch64/aarch64-sve.md > +++ b/gcc/config/aarch64/aarch64-sve.md > @@ -2533,14 +2533,34 @@ > ) > > ;; Duplicate an Advanced SIMD vector to fill an SVE vector (LE version). > -(define_insn "@aarch64_vec_duplicate_vq<mode>_le" > - [(set (match_operand:SVE_FULL 0 "register_operand" "=w") > + > +(define_insn_and_split "@aarch64_vec_duplicate_vq<mode>_le" > + [(set (match_operand:SVE_FULL 0 "register_operand" "=w, w") > (vec_duplicate:SVE_FULL > - (match_operand:<V128> 1 "register_operand" "w")))] > + (match_operand:<V128> 1 "aarch64_sve_dup_ld1rq_operand" "w, UtQ"))) > + (clobber (match_scratch:VNx16BI 2 "=X, Upl"))] > "TARGET_SVE && !BYTES_BIG_ENDIAN" > { > - operands[1] = gen_rtx_REG (<MODE>mode, REGNO (operands[1])); > - return "dup\t%0.q, %1.q[0]"; > + switch (which_alternative) > + { > + case 0: > + operands[1] = gen_rtx_REG (<MODE>mode, REGNO (operands[1])); > + return "dup\t%0.q, %1.q[0]"; > + case 1: > + return "#"; > + default: > + gcc_unreachable (); > + } > + } > + "&& MEM_P (operands[1])" > + [(const_int 0)] > + { > + if (GET_CODE (operands[2]) == SCRATCH) > + operands[2] = gen_reg_rtx (VNx16BImode); > + emit_move_insn (operands[2], CONSTM1_RTX (VNx16BImode)); > + rtx gp = gen_lowpart (<VPRED>mode, operands[2]); > + emit_insn (gen_aarch64_sve_ld1rq<mode> (operands[0], operands[1], gp)); > + DONE; > } > ) > > diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md > index ff7f73d3f30..6062f37025e 100644 > --- a/gcc/config/aarch64/predicates.md > +++ b/gcc/config/aarch64/predicates.md > @@ -676,6 +676,10 @@ > (ior (match_operand 0 "register_operand") > (match_operand 0 "aarch64_sve_ld1r_operand"))) > > +(define_predicate "aarch64_sve_dup_ld1rq_operand" > + (ior (match_operand 0 "register_operand") > + (match_operand 0 "aarch64_sve_ld1rq_operand"))) > + > (define_predicate "aarch64_sve_ptrue_svpattern_immediate" > (and (match_code "const") > (match_test "aarch64_sve_ptrue_svpattern_p (op, NULL)"))) > diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c > index 196de3f5e0a..c38204e6874 100644 > --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c > +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c > @@ -26,4 +26,4 @@ TEST(svfloat64_t, float64_t, f64) > > TEST(svbfloat16_t, bfloat16_t, bf16) > > -/* { dg-final { scan-assembler-times {\tdup\tz[0-9]+\.q, z[0-9]+\.q\[0\]} 12 { target aarch64_little_endian } } } */ > +/* { dg-final { scan-assembler-not {\tdup\t} } } */ It would be good to add something like: /* { dg-final { scan-assembler-times {\tld1rq\t} 12 } } */ (I assume it'll pass for both endiannesses, but please check!), in addition to the scan-assembler-not. OK with that change, thanks. Richard
On Thu, 12 Jan 2023 at 21:02, Richard Sandiford <richard.sandiford@arm.com> wrote: > > Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> writes: > > On Fri, 5 Aug 2022 at 17:49, Richard Sandiford > > <richard.sandiford@arm.com> wrote: > >> > >> Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> writes: > >> > Hi Richard, > >> > Following from off-list discussion, in the attached patch, I wrote pattern > >> > similar to vec_duplicate<mode>_reg, which seems to work for the svld1rq tests. > >> > Does it look OK ? > >> > > >> > Sorry, I didn't fully understand your suggestion on integrating with > >> > vec_duplicate<mode>_reg > >> > pattern. For vec_duplicate<mode>_reg, the operand to vec_duplicate expects > >> > mode to be <VEL>, while the pattern in patch expects operand of > >> > vec_duplicate to have mode <V128>. > >> > How do we write a pattern so an operand can accept either of the 2 modes ? > >> > >> I quoted the wrong one, sorry, should have been > >> aarch64_vec_duplicate_vq<mode>_le. > >> > >> > Also it seems <V128> cannot be used with SVE_ALL ? > >> > >> Yeah, these would be SVE_FULL only. > > Hi Richard, > > Sorry for the very late reply. I have attached patch, to integrate > > with vec_duplicate_vq<mode>_le. > > Bootstrapped+tested on aarch64-linux-gnu. > > OK to commit ? > > > > Thanks, > > Prathamesh > >> > >> Richard > >> > > > > gcc/ > > * config/aarch64/aarch64-sve.md (aarch64_vec_duplicate_vq<mode>_le): > > Change to define_insn_and_split to fold ldr+dup to ld1rq. > > * config/aarch64/predicates.md (aarch64_sve_dup_ld1rq_operand): New. > > > > testsuite/ > > * gcc.target/aarch64/sve/acle/general/pr96463-2.c: Adjust. > > > > diff --git a/gcc/config/aarch64/aarch64-sve.md b/gcc/config/aarch64/aarch64-sve.md > > index b8cc47ef5fc..4548375b8d6 100644 > > --- a/gcc/config/aarch64/aarch64-sve.md > > +++ b/gcc/config/aarch64/aarch64-sve.md > > @@ -2533,14 +2533,34 @@ > > ) > > > > ;; Duplicate an Advanced SIMD vector to fill an SVE vector (LE version). > > -(define_insn "@aarch64_vec_duplicate_vq<mode>_le" > > - [(set (match_operand:SVE_FULL 0 "register_operand" "=w") > > + > > +(define_insn_and_split "@aarch64_vec_duplicate_vq<mode>_le" > > + [(set (match_operand:SVE_FULL 0 "register_operand" "=w, w") > > (vec_duplicate:SVE_FULL > > - (match_operand:<V128> 1 "register_operand" "w")))] > > + (match_operand:<V128> 1 "aarch64_sve_dup_ld1rq_operand" "w, UtQ"))) > > + (clobber (match_scratch:VNx16BI 2 "=X, Upl"))] > > "TARGET_SVE && !BYTES_BIG_ENDIAN" > > { > > - operands[1] = gen_rtx_REG (<MODE>mode, REGNO (operands[1])); > > - return "dup\t%0.q, %1.q[0]"; > > + switch (which_alternative) > > + { > > + case 0: > > + operands[1] = gen_rtx_REG (<MODE>mode, REGNO (operands[1])); > > + return "dup\t%0.q, %1.q[0]"; > > + case 1: > > + return "#"; > > + default: > > + gcc_unreachable (); > > + } > > + } > > + "&& MEM_P (operands[1])" > > + [(const_int 0)] > > + { > > + if (GET_CODE (operands[2]) == SCRATCH) > > + operands[2] = gen_reg_rtx (VNx16BImode); > > + emit_move_insn (operands[2], CONSTM1_RTX (VNx16BImode)); > > + rtx gp = gen_lowpart (<VPRED>mode, operands[2]); > > + emit_insn (gen_aarch64_sve_ld1rq<mode> (operands[0], operands[1], gp)); > > + DONE; > > } > > ) > > > > diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md > > index ff7f73d3f30..6062f37025e 100644 > > --- a/gcc/config/aarch64/predicates.md > > +++ b/gcc/config/aarch64/predicates.md > > @@ -676,6 +676,10 @@ > > (ior (match_operand 0 "register_operand") > > (match_operand 0 "aarch64_sve_ld1r_operand"))) > > > > +(define_predicate "aarch64_sve_dup_ld1rq_operand" > > + (ior (match_operand 0 "register_operand") > > + (match_operand 0 "aarch64_sve_ld1rq_operand"))) > > + > > (define_predicate "aarch64_sve_ptrue_svpattern_immediate" > > (and (match_code "const") > > (match_test "aarch64_sve_ptrue_svpattern_p (op, NULL)"))) > > diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c > > index 196de3f5e0a..c38204e6874 100644 > > --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c > > +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c > > @@ -26,4 +26,4 @@ TEST(svfloat64_t, float64_t, f64) > > > > TEST(svbfloat16_t, bfloat16_t, bf16) > > > > -/* { dg-final { scan-assembler-times {\tdup\tz[0-9]+\.q, z[0-9]+\.q\[0\]} 12 { target aarch64_little_endian } } } */ > > +/* { dg-final { scan-assembler-not {\tdup\t} } } */ > > It would be good to add something like: > > /* { dg-final { scan-assembler-times {\tld1rq\t} 12 } } */ > > (I assume it'll pass for both endiannesses, but please check!), > in addition to the scan-assembler-not. > > OK with that change, thanks. Thanks, committed the patch in a3b99b84609af310c72b4d6221621f5b63a3c169 after adjusting the test-case, and verifying that we generate ld1rq for big endian targets, and bootstrap+test on aarch64-linux-gnu. Thanks, Prathamesh > > Richard
diff --git a/gcc/config/aarch64/aarch64-sve.md b/gcc/config/aarch64/aarch64-sve.md index bd60e65b0c3..b0dc33870b8 100644 --- a/gcc/config/aarch64/aarch64-sve.md +++ b/gcc/config/aarch64/aarch64-sve.md @@ -2504,6 +2504,27 @@ } ) +;; Fold ldr+dup -> ld1rq + +(define_insn_and_split "*vec_duplicate<mode>_ld1rq" + [(set (match_operand:SVE_FULL 0 "register_operand" "=w") + (vec_duplicate:SVE_FULL + (match_operand:<V128> 1 "aarch64_sve_ld1rq_operand" "UtQ"))) + (clobber (match_scratch:VNx16BI 2 "=Upl"))] + "TARGET_SVE" + "#" + "&& 1" + [(const_int 0)] + { + if (GET_CODE (operands[2]) == SCRATCH) + operands[2] = gen_reg_rtx (VNx16BImode); + emit_move_insn (operands[2], CONSTM1_RTX (VNx16BImode)); + rtx gp = gen_lowpart (<VPRED>mode, operands[2]); + emit_insn (gen_aarch64_sve_ld1rq<mode> (operands[0], operands[1], gp)); + DONE; + } +) + ;; Accept memory operands for the benefit of combine, and also in case ;; the scalar input gets spilled to memory during RA. We want to split ;; the load at the first opportunity in order to allow the PTRUE to be diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c index 196de3f5e0a..0dfe125507f 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/pr96463-2.c @@ -26,4 +26,8 @@ TEST(svfloat64_t, float64_t, f64) TEST(svbfloat16_t, bfloat16_t, bf16) -/* { dg-final { scan-assembler-times {\tdup\tz[0-9]+\.q, z[0-9]+\.q\[0\]} 12 { target aarch64_little_endian } } } */ +/* { dg-final { scan-assembler-not "dup" { target aarch64_little_endian } } } */ +/* { dg-final { scan-assembler-times {\tld1rqb\tz0\.b, p0/z, \[x0\]} 2 { target aarch64_little_endian } } } */ +/* { dg-final { scan-assembler-times {\tld1rqh\tz0\.h, p0/z, \[x0\]} 4 { target aarch64_little_endian } } } */ +/* { dg-final { scan-assembler-times {\tld1rqw\tz0\.s, p0/z, \[x0\]} 3 { target aarch64_little_endian } } } */ +/* { dg-final { scan-assembler-times {\tld1rqd\tz0\.d, p0/z, \[x0\]} 3 { target aarch64_little_endian } } } */