From 9fc9573f9a5e9432e53c7de93985cfbd267f0309 Mon Sep 17 00:00:00 2001 From: Joel Hutton Date: Thu, 19 Nov 2020 10:39:38 +0000 Subject: [2/3] [vect] Add widening add, subtract patterns Add widening add, subtract patterns to tree-vect-patterns. Update the widened code of patterns that detect PLUS_EXPR to also detect WIDEN_PLUS_EXPR. These patterns take 2 vectors with N elements of size S and perform an add/subtract on the elements, storing the results as N elements of size 2*S (in 2 result vectors). This is implemented in the aarch64 backend as addl,addl2 and subl,subl2 respectively. Add aarch64 tests for patterns. gcc/ChangeLog: * doc/generic.texi: Document new widen_plus/minus_lo/hi tree codes. * doc/md.texi: Document new widenening add/subtract hi/lo optabs. * expr.c (expand_expr_real_2): Add widen_add, widen_subtract cases. * optabs-tree.c (optab_for_tree_code): Add case for widening optabs. * optabs.def (OPTAB_D): Define vectorized widen add, subtracts. * tree-cfg.c (verify_gimple_assign_binary): Add case for widening adds, subtracts. * tree-inline.c (estimate_operator_cost): Add case for widening adds, subtracts. * tree-vect-generic.c (expand_vector_operations_1): Add case for widening adds, subtracts * tree-vect-patterns.c (vect_recog_widen_add_pattern): New recog pattern. (vect_recog_widen_sub_pattern): New recog pattern. (vect_recog_average_pattern): Update widened add code. (vect_recog_average_pattern): Update widened add code. * tree-vect-stmts.c (vectorizable_conversion): Add case for widened add, subtract. (supportable_widening_operation): Add case for widened add, subtract. * tree.def (WIDEN_PLUS_EXPR): New tree code. (WIDEN_MINUS_EXPR): New tree code. (VEC_WIDEN_ADD_HI_EXPR): New tree code. (VEC_WIDEN_PLUS_LO_EXPR): New tree code. (VEC_WIDEN_MINUS_HI_EXPR): New tree code. (VEC_WIDEN_MINUS_LO_EXPR): New tree code. gcc/testsuite/ChangeLog: * gcc.target/aarch64/vect-widen-add.c: New test. * gcc.target/aarch64/vect-widen-sub.c: New test. --- gcc/doc/generic.texi | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'gcc/doc/generic.texi') diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi index 5c1d3cd..9791f8b 100644 --- a/gcc/doc/generic.texi +++ b/gcc/doc/generic.texi @@ -1798,6 +1798,10 @@ a value from @code{enum annot_expr_kind}, the third is an @code{INTEGER_CST}. @tindex VEC_RSHIFT_EXPR @tindex VEC_WIDEN_MULT_HI_EXPR @tindex VEC_WIDEN_MULT_LO_EXPR +@tindex VEC_WIDEN_PLUS_HI_EXPR +@tindex VEC_WIDEN_PLUS_LO_EXPR +@tindex VEC_WIDEN_MINUS_HI_EXPR +@tindex VEC_WIDEN_MINUS_LO_EXPR @tindex VEC_UNPACK_HI_EXPR @tindex VEC_UNPACK_LO_EXPR @tindex VEC_UNPACK_FLOAT_HI_EXPR @@ -1844,6 +1848,33 @@ vector of @code{N/2} products. In the case of @code{VEC_WIDEN_MULT_LO_EXPR} the low @code{N/2} elements of the two vector are multiplied to produce the vector of @code{N/2} products. +@item VEC_WIDEN_PLUS_HI_EXPR +@itemx VEC_WIDEN_PLUS_LO_EXPR +These nodes represent widening vector addition of the high and low parts of +the two input vectors, respectively. Their operands are vectors that contain +the same number of elements (@code{N}) of the same integral type. The result +is a vector that contains half as many elements, of an integral type whose size +is twice as wide. In the case of @code{VEC_WIDEN_PLUS_HI_EXPR} the high +@code{N/2} elements of the two vectors are added to produce the vector of +@code{N/2} products. In the case of @code{VEC_WIDEN_PLUS_LO_EXPR} the low +@code{N/2} elements of the two vectors are added to produce the vector of +@code{N/2} products. + +@item VEC_WIDEN_MINUS_HI_EXPR +@itemx VEC_WIDEN_MINUS_LO_EXPR +These nodes represent widening vector subtraction of the high and low parts of +the two input vectors, respectively. Their operands are vectors that contain +the same number of elements (@code{N}) of the same integral type. The high/low +elements of the second vector are subtracted from the high/low elements of the +first. The result is a vector that contains half as many elements, of an +integral type whose size is twice as wide. In the case of +@code{VEC_WIDEN_MINUS_HI_EXPR} the high @code{N/2} elements of the second +vector are subtracted from the high @code{N/2} of the first to produce the +vector of @code{N/2} products. In the case of +@code{VEC_WIDEN_MINUS_LO_EXPR} the low @code{N/2} elements of the second +vector are subtracted from the low @code{N/2} of the first to produce the +vector of @code{N/2} products. + @item VEC_UNPACK_HI_EXPR @itemx VEC_UNPACK_LO_EXPR These nodes represent unpacking of the high and low parts of the input vector, -- cgit v1.1