From c30efd8cd634f8a59bc1bf52e71d8866bf52d56c Mon Sep 17 00:00:00 2001 From: Robin Dapp Date: Wed, 28 Jun 2023 15:48:55 +0200 Subject: gimple-isel: Recognize vec_extract pattern. In gimple-isel we already deduce a vec_set pattern from an ARRAY_REF(VIEW_CONVERT_EXPR). This patch does the same for a vec_extract. The code is largely similar to the vec_set one including the addition of a can_vec_extract_var_idx_p function in optabs.cc to check if the backend can handle a register operand as index. We already have can_vec_extract in optabs-query but that one checks whether we can extract specific modes. With the introduction of an internal function for vec_extract the expander must not FAIL. For vec_set this has already been the case so adjust the documentation accordingly. Additionally, clarify the wording of the vector-vector case for vec_extract. gcc/ChangeLog: * doc/md.texi: Document that vec_set and vec_extract must not fail. * gimple-isel.cc (gimple_expand_vec_set_expr): Rename this... (gimple_expand_vec_set_extract_expr): ...to this. (gimple_expand_vec_exprs): Call renamed function. * internal-fn.cc (vec_extract_direct): Add. (expand_vec_extract_optab_fn): New function to expand vec_extract optab. (direct_vec_extract_optab_supported_p): Add. * internal-fn.def (VEC_EXTRACT): Add. * optabs.cc (can_vec_extract_var_idx_p): New function. * optabs.h (can_vec_extract_var_idx_p): Declare. --- gcc/doc/md.texi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gcc/doc/md.texi') diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index f14dd32..b30a824 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -5091,6 +5091,8 @@ Mask elements @var{i} with @var{i} > (operand 5 + operand 6) are ignored. Set given field in the vector value. Operand 0 is the vector to modify, operand 1 is new value of field and operand 2 specify the field index. +This pattern is not allowed to @code{FAIL}. + @cindex @code{vec_extract@var{m}@var{n}} instruction pattern @item @samp{vec_extract@var{m}@var{n}} Extract given field from the vector value. Operand 1 is the vector, operand 2 @@ -5098,7 +5100,10 @@ specify field index and operand 0 place to store value into. The @var{n} mode is the mode of the field or vector of fields that should be extracted, should be either element mode of the vector mode @var{m}, or a vector mode with the same element mode and smaller number of elements. -If @var{n} is a vector mode, the index is counted in units of that mode. +If @var{n} is a vector mode the index is counted in multiples of +mode @var{n}. + +This pattern is not allowed to @code{FAIL}. @cindex @code{vec_init@var{m}@var{n}} instruction pattern @item @samp{vec_init@var{m}@var{n}} -- cgit v1.1