On Mon, Mar 21, 2016 at 11:16 AM, Ilya Enkovich <enkovich....@gmail.com> wrote:
> Hi,
>
> This patch makes an integer vector type to always be used for
> type checks when building a vector conditional expression.
> With no this patch we may get a type of vector comparison
> which may have non-vector mode and different size in case
> of scalar masks usage.
>
> Bootstrapped and regetsted on x86_64-pc-linux-gnu.  OK for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> Ilya
> --
> gcc/cp/
>
> 2016-03-21  Ilya Enkovich  <enkovich....@gmail.com>
>
>         * call.c (build_conditional_expr_1): Always use original
>         condition type for vector type checks and build.
>
> gcc/testsuite/
>
> 2016-03-21  Ilya Enkovich  <enkovich....@gmail.com>
>
>         * g++.dg/ext/pr70290.C: New test.
>
>
> diff --git a/gcc/cp/call.c b/gcc/cp/call.c
> index 1edbce8..d3a256c 100644
> --- a/gcc/cp/call.c
> +++ b/gcc/cp/call.c
> @@ -4634,6 +4634,8 @@ build_conditional_expr_1 (location_t loc, tree arg1, 
> tree arg2, tree arg3,
>
>    if (VECTOR_INTEGER_TYPE_P (TREE_TYPE (arg1)))
>      {
> +      tree arg1_type = TREE_TYPE (arg1);
> +
>        /* If arg1 is another cond_expr choosing between -1 and 0,
>          then we can use its comparison.  It may help to avoid
>          additional comparison, produce more accurate diagnostics
> @@ -4653,7 +4655,6 @@ build_conditional_expr_1 (location_t loc, tree arg1, 
> tree arg2, tree arg3,
>           || error_operand_p (arg3))
>         return error_mark_node;
>
> -      tree arg1_type = TREE_TYPE (arg1);
>        arg2_type = TREE_TYPE (arg2);
>        arg3_type = TREE_TYPE (arg3);
>
> diff --git a/gcc/testsuite/g++.dg/ext/pr70290.C 
> b/gcc/testsuite/g++.dg/ext/pr70290.C
> new file mode 100644
> index 0000000..6de13ce
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/ext/pr70290.C
> @@ -0,0 +1,18 @@
> +/* { dg-do compile } */
> +/* { dg-additional-options "-mavx512vl" { target { i?86-*-* x86_64-*-* } } } 
> */
> +
> +typedef int vec __attribute__((vector_size(32)));
> +
> +vec
> +test1 (vec x,vec y)
> +{
> +  return (x < y) ? 1 : 0;
> +}
> +
> +vec
> +test2 (vec x,vec y)
> +{
> +  vec zero = { };
> +  vec one = zero + 1;
> +  return (x < y) ? one : zero;
> +}

Reply via email to