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

            Bug ID: 112438
           Summary: RISC-V: Failed to AVL propagation through induction
                    variable
           Product: gcc
           Version: 14.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: ---

void
foo (int n, int * __restrict in, int * __restrict out)
{
  for (int i = 0; i < n; i += 1)
    {
      out[i] = in[i] + i;
    }
}

ASM:

foo(int, int*, int*):
        ble     a0,zero,.L5
        csrr    a5,vlenb
        srli    a5,a5,2
        vsetvli a3,zero,e32,m1,ta,ma
        vmv.v.x v4,a5
        vid.v   v2
.L3:
        vsetvli a5,a0,e32,m1,ta,ma
        slli    a4,a5,2
        vle32.v v1,0(a1)
        sub     a0,a0,a5
        vadd.vv v1,v1,v2
        vse32.v v1,0(a2)
        add     a1,a1,a4
        vsetvli a5,zero,e32,m1,ta,ma --- > redundant
        add     a2,a2,a4
        vadd.vv v2,v2,v4
        bne     a0,zero,.L3
.L5:
        ret

It's known issue that I realized it when I was supporting AVL propagation.
Now, I find the time to support AVL propagation now.

Reply via email to