;;
;; [vaddvq_s, vaddvq_u])
;;
-(define_insn "mve_vaddvq_<supf><mode>"
+(define_insn "@mve_vaddvq_<supf><mode>"
[
(set (match_operand:SI 0 "s_register_operand" "=Te")
(unspec:SI [(match_operand:MVE_2 1 "s_register_operand" "w")]
DONE;
})
-(define_expand "reduc_plus_scal_<mode>"
- [(match_operand:<V_elem> 0 "nonimmediate_operand")
- (match_operand:VQ 1 "s_register_operand")]
- "ARM_HAVE_NEON_<MODE>_ARITH && !BYTES_BIG_ENDIAN"
-{
- rtx step1 = gen_reg_rtx (<V_HALF>mode);
-
- emit_insn (gen_quad_halves_plus<mode> (step1, operands[1]));
- emit_insn (gen_reduc_plus_scal_<V_half> (operands[0], step1));
-
- DONE;
-})
-
(define_expand "reduc_plus_scal_v2di"
[(match_operand:DI 0 "nonimmediate_operand")
(match_operand:V2DI 1 "s_register_operand")]
emit_insn (gen_mve_vst4q<mode> (operands[0], operands[1]));
DONE;
})
+
+(define_expand "reduc_plus_scal_<mode>"
+ [(match_operand:<V_elem> 0 "nonimmediate_operand")
+ (match_operand:VQ 1 "s_register_operand")]
+ "ARM_HAVE_<MODE>_ARITH
+ && !(TARGET_HAVE_MVE && FLOAT_MODE_P (<MODE>mode))
+ && !BYTES_BIG_ENDIAN"
+{
+ if (TARGET_NEON)
+ {
+ rtx step1 = gen_reg_rtx (<V_HALF>mode);
+
+ emit_insn (gen_quad_halves_plus<mode> (step1, operands[1]));
+ emit_insn (gen_reduc_plus_scal_<V_half> (operands[0], step1));
+ }
+ else
+ {
+ /* vaddv generates a 32 bits accumulator. */
+ rtx op0 = gen_reg_rtx (SImode);
+
+ emit_insn (gen_mve_vaddvq (VADDVQ_S, <MODE>mode, op0, operands[1]));
+ emit_move_insn (operands[0], gen_lowpart (<V_elem>mode, op0));
+ }
+
+ DONE;
+})
--- /dev/null
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_v8_1m_mve_ok } */
+/* { dg-add-options arm_v8_1m_mve } */
+/* { dg-additional-options "-O3" } */
+
+#include <stdint.h>
+
+#define FUNC(SIGN, TYPE, BITS, NB) \
+ TYPE##32_t test_ ##_ ## SIGN ## BITS ## x ## NB (TYPE##BITS##_t *a) { \
+ int i; \
+ TYPE##BITS##_t result = 0; \
+ for (i=0; i<NB; i++) { \
+ result += a[i]; \
+ } \
+ return result; \
+}
+
+/* 128-bit vectors. */
+FUNC(s, int, 8, 16)
+FUNC(u, uint, 8, 16)
+FUNC(s, int, 16, 8)
+FUNC(u, uint, 16, 8)
+FUNC(s, int, 32, 4)
+FUNC(u, uint, 32, 4)
+
+/* { dg-final { scan-assembler-times {vaddv\.s} 6 } } */