Skip to content
Snippets Groups Projects
Commit 2f482a07 authored by Andre Vieira's avatar Andre Vieira
Browse files

internal-fn,vect: Refactor widen_plus as internal_fn

     DEF_INTERNAL_WIDENING_OPTAB_FN and DEF_INTERNAL_NARROWING_OPTAB_FN
are like DEF_INTERNAL_SIGNED_OPTAB_FN and DEF_INTERNAL_OPTAB_FN
respectively. With the exception that they provide convenience wrappers
for a single vector to vector conversion, a hi/lo split or an even/odd
split.  Each definition for <NAME> will require either signed optabs
named <UOPTAB> and <SOPTAB> (for widening) or a single <OPTAB> (for
narrowing) for each of the five functions it creates.

      For example, for widening addition the
DEF_INTERNAL_WIDENING_OPTAB_FN will create five internal functions:
IFN_VEC_WIDEN_PLUS, IFN_VEC_WIDEN_PLUS_HI, IFN_VEC_WIDEN_PLUS_LO,
IFN_VEC_WIDEN_PLUS_EVEN and IFN_VEC_WIDEN_PLUS_ODD. Each requiring two
optabs, one for signed and one for unsigned.
      Aarch64 implements the hi/lo split optabs:
      IFN_VEC_WIDEN_PLUS_HI   -> vec_widen_<su>add_hi_<mode> -> (u/s)addl2
      IFN_VEC_WIDEN_PLUS_LO  -> vec_widen_<su>add_lo_<mode> -> (u/s)addl

     This gives the same functionality as the previous
WIDEN_PLUS/WIDEN_MINUS tree codes which are expanded into
VEC_WIDEN_PLUS_LO, VEC_WIDEN_PLUS_HI.

2023-06-05  Andre Vieira  <andre.simoesdiasvieira@arm.com>
	    Joel Hutton  <joel.hutton@arm.com>
	    Tamar Christina  <tamar.christina@arm.com>

gcc/ChangeLog:

	* config/aarch64/aarch64-simd.md (vec_widen_<su>addl_lo_<mode>): Rename
	this ...
	(vec_widen_<su>add_lo_<mode>): ... to this.
	(vec_widen_<su>addl_hi_<mode>): Rename this ...
	(vec_widen_<su>add_hi_<mode>): ... to this.
	(vec_widen_<su>subl_lo_<mode>): Rename this ...
	(vec_widen_<su>sub_lo_<mode>): ... to this.
	(vec_widen_<su>subl_hi_<mode>): Rename this ...
	(vec_widen_<su>sub_hi_<mode>): ...to this.
	* doc/generic.texi: Document new IFN codes.
	* internal-fn.cc (lookup_hilo_internal_fn): Add lookup function.
	(commutative_binary_fn_p): Add widen_plus fn's.
	(widening_fn_p): New function.
	(narrowing_fn_p): New function.
	(direct_internal_fn_optab): Change visibility.
	* internal-fn.def (DEF_INTERNAL_WIDENING_OPTAB_FN): Macro to define an
	internal_fn that expands into multiple internal_fns for widening.
	(IFN_VEC_WIDEN_PLUS, IFN_VEC_WIDEN_PLUS_HI, IFN_VEC_WIDEN_PLUS_LO,
	IFN_VEC_WIDEN_PLUS_EVEN, IFN_VEC_WIDEN_PLUS_ODD,
	IFN_VEC_WIDEN_MINUS, IFN_VEC_WIDEN_MINUS_HI,
	IFN_VEC_WIDEN_MINUS_LO, IFN_VEC_WIDEN_MINUS_ODD,
	IFN_VEC_WIDEN_MINUS_EVEN): Define widening  plus,minus functions.
	* internal-fn.h (direct_internal_fn_optab): Declare new prototype.
	(lookup_hilo_internal_fn): Likewise.
	(widening_fn_p): Likewise.
	(Narrowing_fn_p): Likewise.
	* optabs.cc (commutative_optab_p): Add widening plus optabs.
	* optabs.def (OPTAB_D): Define widen add, sub optabs.
	* tree-vect-patterns.cc (vect_recog_widen_op_pattern): Support
	patterns with a hi/lo or even/odd split.
	(vect_recog_sad_pattern): Refactor to use new IFN codes.
	(vect_recog_widen_plus_pattern): Likewise.
	(vect_recog_widen_minus_pattern): Likewise.
	(vect_recog_average_pattern): Likewise.
	* tree-vect-stmts.cc (vectorizable_conversion): Add support for
	_HILO IFNs.
	(supportable_widening_operation): Likewise.
	* tree.def (WIDEN_SUM_EXPR): Update example to use new IFNs.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/vect-widen-add.c: Test that new
	IFN_VEC_WIDEN_PLUS is being used.
	* gcc.target/aarch64/vect-widen-sub.c: Test that new
	IFN_VEC_WIDEN_MINUS is being used.
parent fe29963d
No related branches found
No related tags found
No related merge requests found
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