https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111720
--- Comment #4 from JuzheZhong <juzhe.zhong at rivai dot ai> ---
I found this is not because VLS modes.
with --param=riscv-autovec-preference=fixed-vlmax
disabling VLS modes also see unnecessary load/store:
fn:
lui a5,%hi(.LANCHOR0)
addi sp,sp,-32
addi a5,a5,%lo(.LANCHOR0)
vl2re64.v v8,0(a5) ----- ??? unnecessary
li a4,32
vs2r.v v8,0(sp) ----- ??? unnecessary
vsetvli zero,a4,e8,m1,ta,ma
vle8.v v0,0(sp)
vand.vi v0,v0,1
addi sp,sp,32
jr ra
The optimized tree is reasonable, but after the "expand" stage, the redundant
load and store are produced.