diff mbox series

[V2,1/2] Pass type of comparison operands instead of comparison result to truth_type_for in build_vec_cmp.

Message ID 20231026011432.3484969-1-hongtao.liu@intel.com
State New
Headers show
Series [V2,1/2] Pass type of comparison operands instead of comparison result to truth_type_for in build_vec_cmp. | expand

Commit Message

Liu, Hongtao Oct. 26, 2023, 1:14 a.m. UTC
>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.

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(-)

Comments

Richard Biener Oct. 26, 2023, 8:33 a.m. UTC | #1
On Thu, Oct 26, 2023 at 3:15 AM liuhongt <hongtao.liu@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
>
diff mbox series

Patch

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);
 }