public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/109547] New: RISC-V: Multiple vsetvli for load/store loop
@ 2023-04-18 22:24 palmer at gcc dot gnu.org
  2023-04-19  0:25 ` [Bug target/109547] " kito at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: palmer at gcc dot gnu.org @ 2023-04-18 22:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109547

            Bug ID: 109547
           Summary: RISC-V: Multiple vsetvli for load/store loop
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: palmer at gcc dot gnu.org
  Target Milestone: ---

I was just poking around with a simple loop using the vector intrinsics and
found some odd generated code.  This is on the gcc-13 branch, but that's pretty
close to trunk so I'm filing it for 14.  I'm probably not going to have time to
look for a bit, as it seems to just be a performance issue.

$ cat test.c
#include <riscv_vector.h>

void func(unsigned char *out, unsigned char *in, unsigned long len) {
  unsigned long i = 0;
  while (i < len) {
    unsigned long vl = __riscv_vsetvl_e8m1(len - i);
    vuint8m1_t r = __riscv_vle8_v_u8m1(in + i, vl);
    __riscv_vse8_v_u8m1(out + i, r, vl);
    i += vl;
  }
}
$ ../toolchain/install/bin/riscv64-unknown-linux-gnu-gcc test.c -O3 -c -S -o-
-march=rv64gcv -fdump-rtl-all
        .file   "test.c"
        .option nopic
        .attribute arch,
"rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_v1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0"
        .attribute unaligned_access, 0
        .attribute stack_align, 16
        .text
        .align  1
        .globl  func
        .type   func, @function
func:
.LFB2:
        .cfi_startproc
        beq     a2,zero,.L1
        li      a5,0
.L3:
        sub     a4,a2,a5
        add     a6,a1,a5
        add     a3,a0,a5
        vsetvli a4,a4,e8,m1,ta,mu
        vsetvli zero,a4,e8,m1,ta,ma
        add     a5,a5,a4
        vle8.v  v24,0(a6)
        vse8.v  v24,0(a3)
        bgtu    a2,a5,.L3
.L1:
        ret
        .cfi_endproc
.LFE2:
        .size   func, .-func
        .ident  "GCC: (g85b95ea729c) 13.0.1 20230417 (prerelease)"
        .section        .note.GNU-stack,"",@progbits

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/109547] RISC-V: Multiple vsetvli for load/store loop
  2023-04-18 22:24 [Bug target/109547] New: RISC-V: Multiple vsetvli for load/store loop palmer at gcc dot gnu.org
@ 2023-04-19  0:25 ` kito at gcc dot gnu.org
  2023-04-19  1:01 ` juzhe.zhong at rivai dot ai
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: kito at gcc dot gnu.org @ 2023-04-19  0:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109547

Kito Cheng <kito at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-04-19

--- Comment #1 from Kito Cheng <kito at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/109547] RISC-V: Multiple vsetvli for load/store loop
  2023-04-18 22:24 [Bug target/109547] New: RISC-V: Multiple vsetvli for load/store loop palmer at gcc dot gnu.org
  2023-04-19  0:25 ` [Bug target/109547] " kito at gcc dot gnu.org
@ 2023-04-19  1:01 ` juzhe.zhong at rivai dot ai
  2023-04-21  6:46 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: juzhe.zhong at rivai dot ai @ 2023-04-19  1:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109547

--- Comment #2 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
It has been fixed by one of GCC-14 queue patch:
https://gcc.gnu.org/pipermail/gcc-patches/2023-April/615352.html

Since GCC-13 doesn't allow any optimizations, I can't make it in the GCC 13.

Besides, there are a bunch of patches waiting to be merged:
https://github.com/zhongjuzhe/gcc-14-queue-patches/edit/main/gcc-14-queue-patchs

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/109547] RISC-V: Multiple vsetvli for load/store loop
  2023-04-18 22:24 [Bug target/109547] New: RISC-V: Multiple vsetvli for load/store loop palmer at gcc dot gnu.org
  2023-04-19  0:25 ` [Bug target/109547] " kito at gcc dot gnu.org
  2023-04-19  1:01 ` juzhe.zhong at rivai dot ai
@ 2023-04-21  6:46 ` cvs-commit at gcc dot gnu.org
  2023-04-21  6:51 ` [Bug target/109547] [13] " kito at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-21  6:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109547

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Kito Cheng <kito@gcc.gnu.org>:

https://gcc.gnu.org/g:d51f2456ee51bd59a79b4725ca0e488c25260bbf

commit r14-129-gd51f2456ee51bd59a79b4725ca0e488c25260bbf
Author: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Date:   Fri Apr 7 09:34:13 2023 +0800

    RISC-V: Add local user vsetvl instruction elimination [PR109547]

    This patch is to enhance optimization for auto-vectorization.

    Before this patch:

    Loop:
    vsetvl a5,a2...
    vsetvl zero,a5...
    vle

    After this patch:

    Loop:
    vsetvl a5,a2
    vle

    gcc/ChangeLog:

            PR target/109547
            * config/riscv/riscv-vsetvl.cc (local_eliminate_vsetvl_insn): New
function.
            (vector_insn_info::skip_avl_compatible_p): Ditto.
            (vector_insn_info::merge): Remove default value.
            (pass_vsetvl::compute_local_backward_infos): Ditto.
            (pass_vsetvl::cleanup_insns): Add local vsetvl elimination.
            * config/riscv/riscv-vsetvl.h: Ditto.

    gcc/testsuite/ChangeLog:

            PR target/109547
            * gcc.target/riscv/rvv/vsetvl/pr109547.c: New.
            * gcc.target/riscv/rvv/vsetvl/vsetvl-17.c: Update scan
            condition.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/109547] [13] RISC-V: Multiple vsetvli for load/store loop
  2023-04-18 22:24 [Bug target/109547] New: RISC-V: Multiple vsetvli for load/store loop palmer at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-04-21  6:46 ` cvs-commit at gcc dot gnu.org
@ 2023-04-21  6:51 ` kito at gcc dot gnu.org
  2023-05-29 10:35 ` cvs-commit at gcc dot gnu.org
  2023-05-29 12:47 ` kito at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: kito at gcc dot gnu.org @ 2023-04-21  6:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109547

Kito Cheng <kito at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|RISC-V: Multiple vsetvli    |[13] RISC-V: Multiple
                   |for load/store loop         |vsetvli for load/store loop
   Target Milestone|---                         |13.2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/109547] [13] RISC-V: Multiple vsetvli for load/store loop
  2023-04-18 22:24 [Bug target/109547] New: RISC-V: Multiple vsetvli for load/store loop palmer at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-04-21  6:51 ` [Bug target/109547] [13] " kito at gcc dot gnu.org
@ 2023-05-29 10:35 ` cvs-commit at gcc dot gnu.org
  2023-05-29 12:47 ` kito at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-29 10:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109547

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Kito Cheng <kito@gcc.gnu.org>:

https://gcc.gnu.org/g:98fc9d38db95b3396a8540accc1bc45e71080650

commit r13-7386-g98fc9d38db95b3396a8540accc1bc45e71080650
Author: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Date:   Fri Apr 7 09:34:13 2023 +0800

    RISC-V: Add local user vsetvl instruction elimination [PR109547]

    This patch is to enhance optimization for auto-vectorization.

    Before this patch:

    Loop:
    vsetvl a5,a2...
    vsetvl zero,a5...
    vle

    After this patch:

    Loop:
    vsetvl a5,a2
    vle

    gcc/ChangeLog:

            PR target/109547
            * config/riscv/riscv-vsetvl.cc (local_eliminate_vsetvl_insn): New
function.
            (vector_insn_info::skip_avl_compatible_p): Ditto.
            (vector_insn_info::merge): Remove default value.
            (pass_vsetvl::compute_local_backward_infos): Ditto.
            (pass_vsetvl::cleanup_insns): Add local vsetvl elimination.
            * config/riscv/riscv-vsetvl.h: Ditto.

    gcc/testsuite/ChangeLog:

            PR target/109547
            * gcc.target/riscv/rvv/vsetvl/pr109547.c: New.
            * gcc.target/riscv/rvv/vsetvl/vsetvl-17.c: Update scan
            condition.

    (cherry picked from commit d51f2456ee51bd59a79b4725ca0e488c25260bbf)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/109547] [13] RISC-V: Multiple vsetvli for load/store loop
  2023-04-18 22:24 [Bug target/109547] New: RISC-V: Multiple vsetvli for load/store loop palmer at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-05-29 10:35 ` cvs-commit at gcc dot gnu.org
@ 2023-05-29 12:47 ` kito at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: kito at gcc dot gnu.org @ 2023-05-29 12:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109547

Kito Cheng <kito at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #5 from Kito Cheng <kito at gcc dot gnu.org> ---
Fixed on both trunk and gcc 13

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-29 12:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 22:24 [Bug target/109547] New: RISC-V: Multiple vsetvli for load/store loop palmer at gcc dot gnu.org
2023-04-19  0:25 ` [Bug target/109547] " kito at gcc dot gnu.org
2023-04-19  1:01 ` juzhe.zhong at rivai dot ai
2023-04-21  6:46 ` cvs-commit at gcc dot gnu.org
2023-04-21  6:51 ` [Bug target/109547] [13] " kito at gcc dot gnu.org
2023-05-29 10:35 ` cvs-commit at gcc dot gnu.org
2023-05-29 12:47 ` kito at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).