Skip to content
Snippets Groups Projects
Commit f4f72f9b authored by YunQiang Su's avatar YunQiang Su Committed by YunQiang Su
Browse files

MIPS: Support vector reduc for MSA

We have SHF.fmt and HADD_S/U.fmt with MSA, which can be used for
vector reduc.

For min/max for U8/S8, we can
	SHF.B W1, W0, 0xb1  # swap byte inner every half
	MIN.B W1, W1, W0
	SHF.H W2, W1, 0xb1  # swap half inner every word
	MIN.B W2, W2, W1
	SHF.W W3, W2, 0xb1  # swap word inner every doubleword
	MIN.B W4, W3, W2
	SHF.W W4, W4, 0x4e  # swap the two doubleword
	MIN.B W4, W4, W3

For plus of S8/U8, we can use HADD
	HADD.H	W0, W0, W0
	HADD.W	W0, W0, W0
	HADD.D	W0, W0, W0
	SHF.W	W1, W0, 0x4e  # swap the two doubleword
	ADDV.D	W1, W1, W0
	COPY_S.B  T0, W1      # COPY_U.B for U8

We can do similar for S16/U16/S32/U32/S64/U64/FLOAT/DOUBLE.

gcc

	* config/mips/mips-msa.md: (MSA_NO_HADD): we have HADD for
	S8/U8/S16/U16/S32/U32 only.
	(reduc_smin_scal_<mode>): New define pattern.
	(reduc_smax_scal_<mode>): Ditto.
	(reduc_umin_scal_<mode>): Ditto.
	(reduc_umax_scal_<mode>): Ditto.
	(reduc_plus_scal_<mode>): Ditto.
	(reduc_plus_scal_v4si): Ditto.
	(reduc_plus_scal_v8hi): Ditto.
	(reduc_plus_scal_v16qi): Ditto.
	(reduc_<optab>_scal_<mode>): Ditto.
	* config/mips/mips-protos.h: New function mips_expand_msa_reduc.
	* config/mips/mips.cc: New function mips_expand_msa_reduc.
	* config/mips/mips.md: Define any_bitwise iterator.

gcc/testsuite:

	* gcc.target/mips/msa-reduc.c: New tests.
parent b64980b0
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment