On Thu, Oct 26, 2023 at 3:15 AM liuhongt <hongtao....@intel.com> wrote:
>
> >I think it's indeed on purpose that the result of v1 < v2 is a signed
> >integer vector type.
> >But build_vec_cmp should not use the truth type for the result but instead 
> >the
> >truth type for the comparison, so
>
> Change build_vec_cmp in both c/c++, also notice for jit part, it already uses
> type of comparison instead of the result.

OK if bootstrap/testing succeeds.

Thanks,
Richard.

> gcc/c/ChangeLog:
>
>         * c-typeck.cc (build_vec_cmp): Pass type of arg0 to
>         truth_type_for.
>
> gcc/cp/ChangeLog:
>
>         * typeck.cc (build_vec_cmp): Pass type of arg0 to
>         truth_type_for.
> ---
>  gcc/c/c-typeck.cc | 2 +-
>  gcc/cp/typeck.cc  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
> index e55e887da14..41ee38368f2 100644
> --- a/gcc/c/c-typeck.cc
> +++ b/gcc/c/c-typeck.cc
> @@ -11982,7 +11982,7 @@ build_vec_cmp (tree_code code, tree type,
>  {
>    tree zero_vec = build_zero_cst (type);
>    tree minus_one_vec = build_minus_one_cst (type);
> -  tree cmp_type = truth_type_for (type);
> +  tree cmp_type = truth_type_for (TREE_TYPE (arg0));
>    tree cmp = build2 (code, cmp_type, arg0, arg1);
>    return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec);
>  }
> diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
> index 8132bd7fccc..7b2ad51bde7 100644
> --- a/gcc/cp/typeck.cc
> +++ b/gcc/cp/typeck.cc
> @@ -4826,7 +4826,7 @@ build_vec_cmp (tree_code code, tree type,
>  {
>    tree zero_vec = build_zero_cst (type);
>    tree minus_one_vec = build_minus_one_cst (type);
> -  tree cmp_type = truth_type_for (type);
> +  tree cmp_type = truth_type_for (TREE_TYPE (arg0));
>    tree cmp = build2 (code, cmp_type, arg0, arg1);
>    return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec);
>  }
> --
> 2.31.1
>

Reply via email to