public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/113697] New: RISC-V: Redundant vsetvl insn in function
@ 2024-02-01  1:59 pan2.li at intel dot com
  2024-02-02 17:37 ` [Bug target/113697] " cvs-commit at gcc dot gnu.org
  2024-02-04  0:46 ` pan2.li at intel dot com
  0 siblings, 2 replies; 3+ messages in thread
From: pan2.li at intel dot com @ 2024-02-01  1:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113697
           Summary: RISC-V: Redundant vsetvl insn in function
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pan2.li at intel dot com
  Target Milestone: ---

Give the sample code as below, build with -march=rv64gcv -O3 -g0

int foo (int * __restrict a, int n)
{
    int result = 0;
    for (int i = 0; i < n; i++)
      result += a[i];
    return result;
}

The asm code looks like below, we have one duplicated vsetvl insn here.

foo:
.LFB0:
        .cfi_startproc
        ble     a1,zero,.L4
        vsetvli a5,zero,e32,m1,ta,ma
        vmv.v.i v1,0
.L3:
        vsetvli a5,a1,e32,m1,tu,ma
        slli    a4,a5,2
        sub     a1,a1,a5
        vle32.v v2,0(a0)
        add     a0,a0,a4
        vadd.vv v1,v2,v1
        bne     a1,zero,.L3
        li      a5,0
        vsetivli        zero,1,e32,m1,ta,ma
        vmv.s.x v2,a5
        vsetvli a5,zero,e32,m1,ta,ma  <== redundant vsetvl
        vredsum.vs      v1,v1,v2
        vmv.x.s a0,v1
        ret
.L4:
        li      a0,0
        ret

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

end of thread, other threads:[~2024-02-04  0:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01  1:59 [Bug c/113697] New: RISC-V: Redundant vsetvl insn in function pan2.li at intel dot com
2024-02-02 17:37 ` [Bug target/113697] " cvs-commit at gcc dot gnu.org
2024-02-04  0:46 ` pan2.li at intel dot com

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).