public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "juzhe.zhong at rivai dot ai" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/112092] RISC-V: Wrong RVV code produced for vsetvl-11.c and vsetvlmax-8.c
Date: Thu, 26 Oct 2023 06:51:48 +0000	[thread overview]
Message-ID: <bug-112092-4-0BDzIm8XL9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112092-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
Yes. I am agree that some arch prefer agnostic than undisturbed even with more
vsetvls. That's why I have post PR for asking whether we can have a option like

-mprefer-agosnotic.

https://github.com/riscv-non-isa/riscv-toolchain-conventions/issues/37


But I think Maciej is worrying about why GCC fuse vsetvl, and change

e16mf2 vsetvl into e32m1.


For example:

https://godbolt.org/z/6G9G7Pbe9

No 'TU' included.

I think LLVM codegen looks more reasonable:

        beqz    a5, .LBB0_4
        vsetvli a1, a6, e32, m1, ta, ma
        beqz    a4, .LBB0_3
.LBB0_2:                                # =>This Inner Loop Header: Depth=1
        vsetvli zero, a1, e32, m1, ta, ma
        vle32.v v8, (a0)
        vadd.vv v8, v8, v8
        addi    a4, a4, -1
        vse32.v v8, (a3)
        bnez    a4, .LBB0_2
.LBB0_3:
        ret
.LBB0_4:
        srai    a1, a6, 2
        vsetvli a1, a1, e16, mf2, ta, ma
        bnez    a4, .LBB0_2
        j       .LBB0_3

But GCC is correct with optimizations:

foo(int*, int*, int*, int*, unsigned long, int, int):
        beq     a5,zero,.L2
        vsetvli a5,a6,e32,m1,ta,ma
.L3:
        beq     a4,zero,.L10
        li      a2,0
.L5:
        vle32.v v1,0(a0)
        addi    a2,a2,1
        vadd.vv v1,v1,v1
        vse32.v v1,0(a3)
        bne     a4,a2,.L5
.L10:
        ret
.L2:
        sraiw   a5,a6,2
        vsetvli zero,a5,e32,m1,ta,ma
        j       .L3

  parent reply	other threads:[~2023-10-26  6:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26  1:00 [Bug target/112092] New: " macro at orcam dot me.uk
2023-10-26  1:46 ` [Bug target/112092] " juzhe.zhong at rivai dot ai
2023-10-26  1:57 ` juzhe.zhong at rivai dot ai
2023-10-26  4:01 ` macro at orcam dot me.uk
2023-10-26  6:38 ` kito at gcc dot gnu.org
2023-10-26  6:51 ` juzhe.zhong at rivai dot ai [this message]
2023-10-26  7:08 ` juzhe.zhong at rivai dot ai
2023-10-26 23:31 ` macro at orcam dot me.uk
2023-10-27  0:57 ` juzhe.zhong at rivai dot ai
2023-10-27  1:03 ` juzhe.zhong at rivai dot ai
2023-10-31 13:58 ` [Bug target/112092] RISC-V: Suboptimal " macro at orcam dot me.uk
2023-11-08  6:38 ` cvs-commit at gcc dot gnu.org
2023-11-08  6:39 ` juzhe.zhong at rivai dot ai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-112092-4-0BDzIm8XL9@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).