This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR70026] Fix boolean comparison processing in masks conversion patterns
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Ilya Enkovich <enkovich dot gnu at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 4 Mar 2016 12:55:06 +0100
- Subject: Re: [PATCH, PR70026] Fix boolean comparison processing in masks conversion patterns
- Authentication-results: sourceware.org; auth=none
- References: <20160302160100 dot GA2588 at msticlxl57 dot ims dot intel dot com>
On Wed, Mar 2, 2016 at 5:14 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> This patch fixes mask type determination for boolean values comparison. That avoid incorrect application of masks conversion pattern. Bootstrapped and tested on x86_64-pc-linux-gnu. OK for trunk?
Ok.
Richard.
> Thanks,
> Ilya
> --
> gcc/
>
> 2016-03-02 Ilya Enkovich <enkovich.gnu@gmail.com>
>
> * tree-vect-patterns.c (search_type_for_mask): Handle
> comparison of booleans.
>
>
> gcc/testsuite/
>
> 2016-03-02 Ilya Enkovich <enkovich.gnu@gmail.com>
>
> * gcc.dg/pr70026.c: New test.
>
>
> diff --git a/gcc/testsuite/gcc.dg/pr70026.c b/gcc/testsuite/gcc.dg/pr70026.c
> new file mode 100644
> index 0000000..32f59e2
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr70026.c
> @@ -0,0 +1,15 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O3" } */
> +
> +unsigned int a[64], b[64], c[64], d[64], e[64];
> +
> +void
> +foo ()
> +{
> + int i;
> + for (i = 0; i < 64; i++)
> + {
> + d[i] = a[i];
> + e[i] = ((b[i] < e[i]) != !c[i]) && !a[i];
> + }
> +}
> diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
> index 95ce38d..7037e04 100644
> --- a/gcc/tree-vect-patterns.c
> +++ b/gcc/tree-vect-patterns.c
> @@ -3219,6 +3219,15 @@ search_type_for_mask (tree var, vec_info *vinfo)
> {
> tree comp_vectype, mask_type;
>
> + if (TREE_CODE (TREE_TYPE (rhs1)) == BOOLEAN_TYPE)
> + {
> + res = search_type_for_mask (rhs1, vinfo);
> + res2 = search_type_for_mask (gimple_assign_rhs2 (def_stmt), vinfo);
> + if (!res || (res2 && TYPE_PRECISION (res) > TYPE_PRECISION (res2)))
> + res = res2;
> + break;
> + }
> +
> comp_vectype = get_vectype_for_scalar_type (TREE_TYPE (rhs1));
> if (comp_vectype == NULL_TREE)
> return NULL_TREE;