Prathamesh Kulkarni <prathamesh.kulka...@linaro.org> writes:
> diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
> index c5006afc00d..0a3c733ada9 100644
> --- a/gcc/doc/tm.texi
> +++ b/gcc/doc/tm.texi
> @@ -6088,14 +6088,18 @@ for the given scalar type @var{type}.  
> @var{is_packed} is false if the scalar
>  access using @var{type} is known to be naturally aligned.
>  @end deftypefn
>  
> -@deftypefn {Target Hook} bool TARGET_VECTORIZE_VEC_PERM_CONST (machine_mode 
> @var{mode}, rtx @var{output}, rtx @var{in0}, rtx @var{in1}, const 
> vec_perm_indices @var{&sel})
> +@deftypefn {Target Hook} bool TARGET_VECTORIZE_VEC_PERM_CONST (machine_mode 
> @var{mode}, machine_mode @var{op_mode}, rtx @var{output}, rtx @var{in0}, rtx 
> @var{in1}, const vec_perm_indices @var{&sel})
>  This hook is used to test whether the target can permute up to two
> -vectors of mode @var{mode} using the permutation vector @code{sel}, and
> -also to emit such a permutation.  In the former case @var{in0}, @var{in1}
> -and @var{out} are all null.  In the latter case @var{in0} and @var{in1} are
> -the source vectors and @var{out} is the destination vector; all three are
> -operands of mode @var{mode}.  @var{in1} is the same as @var{in0} if
> -@var{sel} describes a permutation on one vector instead of two.
> +vectors of mode @var{op_mode} using the permutation vector @code{sel},
> +producing a vector of mode @var{mode}.The hook is also used to emit such

Should be two spaces between “@var{mode}.” and “The”.

> +a permutation.
> +
> +When the hook is being used to test whether the target supports a 
> permutation,
> +@var{in0}, @var{in1}, and @var{out} are all null.When the hook is being used

Same here: missing spaces before “When”.

> +to emit a permutation, @var{in0} and @var{in1} are the source vectors of mode
> +@var{op_mode} and @var{out} is the destination vector of mode @var{mode}.
> +@var{in1} is the same as @var{in0} if @var{sel} describes a permutation on 
> one
> +vector instead of two.
>  
>  Return true if the operation is possible, emitting instructions for it
>  if rtxes are provided.
> diff --git a/gcc/match.pd b/gcc/match.pd
> index f5efa77560c..f2a527d9c42 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -7596,6 +7596,8 @@ and,
>   (with
>    {
>      tree op0 = @0, op1 = @1, op2 = @2;
> +    machine_mode result_mode = TYPE_MODE (type);
> +    machine_mode op_mode = TYPE_MODE (TREE_TYPE (op0));
>  
>      /* Build a vector of integers from the tree mask.  */
>      vec_perm_builder builder;
> @@ -7703,12 +7705,12 @@ and,
>              2-argument version.  */
>           tree oldop2 = op2;
>           if (sel.ninputs () == 2
> -            || can_vec_perm_const_p (TYPE_MODE (type), sel, false))
> +            || can_vec_perm_const_p (result_mode, op_mode, sel, false))
>             op2 = vec_perm_indices_to_tree (TREE_TYPE (op2), sel);
>           else
>             {
>               vec_perm_indices sel2 (builder, 2, nelts);
> -             if (can_vec_perm_const_p (TYPE_MODE (type), sel2, false))
> +             if (can_vec_perm_const_p (result_mode, op_mode, sel2, false))
>                 op2 = vec_perm_indices_to_tree (TREE_TYPE (op2), sel2);
>               else
>                 /* Not directly supported with either encoding,

Please replace the use of TYPE_MODE here:

        /* See if the permutation is performing a single element
           insert from a CONSTRUCTOR or constant and use a BIT_INSERT_EXPR
           in that case.  But only if the vector mode is supported,
           otherwise this is invalid GIMPLE.  */
        if (TYPE_MODE (type) != BLKmode

as well.

OK with those changes, thanks.

Richard

Reply via email to