https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117733
--- Comment #6 from Robin Dapp <rdapp at gcc dot gnu.org> ---
> This version of the loop is about 50% faster on Ascalon. A shortened run of
> bwaves is also more than 10% faster. Is there a vector cost issue here? An
> issue with riscv_sched_reorder grouping same configuration instructions too?
It's not costing nor scheduling. You can disable scheduling by
-fno-schedule-insns -fno-schedule-insns2, it'll be even worse then.
Full unrolling makes things considerably worse (appearance wise) but if we
disable it (-fdisable-tree-cunrolli) I think it just looks better WRT vsetvlis
but is not actually much faster (length of 1 for the vfmacc). The vsetvlis in
your snippet are all different as we're operating on 5 different lengths in
parallel so they cannot be merged.
We cannot choose between partial and non-partial vectorization during costing,
that decision is made earlier. The issue is (see also upthread) that we cannot
fit an unrolled "group" of 5 into a vector and would need a vector size of 5 *
4 or something, hence re-rolling (i.e. un-unrolling).
Without unrolling and an LMUL2 vector that fits one iteration, it can work:
-O3 -march=rva23u64_zvl256b bla.c -S -mrvv-max-lmul=m2
--param=riscv-autovec-mode=RVVM2DF -fdisable-tree-cunrolli -fno-vect-cost-model
This gets us:
f:
.LFB0:
.cfi_startproc
ble a2,zero,.L5
sh2add a2,a2,a2
sh3add a5,a2,a0
vsetvli a4,zero,e64,m2,ta,ma
vfmv.v.f v6,fa0
vsetivli zero,5,e64,m2,ta,ma
.L3:
vle64.v v2,0(a0)
vle64.v v4,0(a1)
vfmacc.vv v2,v6,v4
vse64.v v2,0(a0)
addi a0,a0,40
addi a1,a1,40
bne a5,a0,.L3
.L5:
ret