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

            Bug ID: 115819
           Summary: RISC-V: Failed to hoist vrsub.vx to the header of the
                    loop
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: juzhe.zhong at rivai dot ai
  Target Milestone: ---

https://godbolt.org/z/K119cG14h

void foo (int *__restrict A, int n) {
    for (int i = n; i > 0; --i) {
        A[i] += 1;
    }
}

        vsetvli a4,zero,e32,m1,ta,ma
        add     a5,a5,a3
        vid.v   v2
        add     a5,a0,a5
        subw    t3,a1,t1
        li      a2,0
.L4:
        vl1re32.v       v3,0(a5)
        vrsub.vx        v5,v2,a6   -----> should be hoisted
        addw    a2,a2,t1
        vrgather.vv     v1,v3,v5
        vadd.vi v1,v1,1
        vrgather.vv     v3,v1,v5
        vs1r.v  v3,0(a5)

Reply via email to