diff mbox

[PR70026] Fix boolean comparison processing in masks conversion patterns

Message ID 20160302160100.GA2588@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich March 2, 2016, 4:14 p.m. UTC
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?

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.

Comments

Richard Biener March 4, 2016, 11:55 a.m. UTC | #1
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;
diff mbox

Patch

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;