LoongArch: Add reduc_widen_<su>sum optab support
Add reduc_widen_ssum and reduc_widen_usum expansions for LSX and LASX.
LoongArch has no accumulating form of vhaddw, so chain pairwise widening
adds and merge the result into the accumulator with one vector add.
Cover half-, quarter-, and eighth-width reductions.
---
Changes in v2:
- Replace `rtx (*gen) (rtx, rtx, rtx)` with
`rtx_insn *(*gen) (rtx, rtx, rtx)` for r17-6440.
gcc/ChangeLog:
* config/loongarch/loongarch-protos.h
(loongarch_expand_reduc_widen_sum): Declare.
* config/loongarch/loongarch.cc
(loongarch_emit_widen_pair_sum): New function.
(loongarch_expand_reduc_widen_sum): New function.
* config/loongarch/simd.md
(IVEC_WS_2, IVEC_WS_4, IVEC_WS_8): New mode iterators.
(WVEC_OCT, wvec_oct): New mode attributes.
(reduc_widen_<su>sum<wvec_half><mode>3): New expand.
(reduc_widen_<su>sum<wvec_quarter><mode>3): New expand.
(reduc_widen_<su>sum<wvec_oct><mode>3): New expand.
gcc/testsuite/ChangeLog:
* lib/target-supports.exp
(check_effective_target_vect_widen_sum_hi_to_si_pattern):
Support LoongArch.
* gcc.target/loongarch/vector/lasx/reduc-widen-sum.c: New test.
* gcc.target/loongarch/vector/lsx/reduc-widen-sum.c: New test.
6 files changed