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

--- Comment #7 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
(In reply to Kito Cheng from comment #6)
> The key is the splat of VLMAX instruction need move into loop body, but AVL
> propagation should still able to do:
> 
> ```
> foo(int, int*, int*):
>         ble     a0,zero,.L5
>         csrr    a5,vlenb
>         srli    a5,a5,2
>         vsetvli a3,zero,e32,m1,ta,ma
>         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
>         vmv.v.x v4,a5           # Move to here, splat vl to a5 rather than
> VLMAX
>         vsetvli a5,zero,e32,m1,ta,ma --- > redundant
> 
>         add     a2,a2,a4
>         vadd.vv v2,v2,v4
>         bne     a0,zero,.L3
> .L5:
>         ret
> ```

Oh. I understand it now. I think it's a bug.

And.. I just take a look at my internal LLVM...
Also has same issue....

I think we need to adapt the Gimple IR here:

  _35 = .SELECT_VL (ivtmp_33, POLY_INT_CST [4, 4]);
  _21 = vect_vec_iv_.6_22 + { POLY_INT_CST [4, 4], ... };

change it into:

  _35 = .SELECT_VL (ivtmp_33, POLY_INT_CST [4, 4]);
  _21 = vect_vec_iv_.6_22 + _35;

Reply via email to