public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR70026] Fix boolean comparison processing in masks conversion patterns
@ 2016-03-02 16:15 Ilya Enkovich
  2016-03-04 11:55 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Ilya Enkovich @ 2016-03-02 16:15 UTC (permalink / raw)
  To: gcc-patches

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.


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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, PR70026] Fix boolean comparison processing in masks conversion patterns
  2016-03-02 16:15 [PATCH, PR70026] Fix boolean comparison processing in masks conversion patterns Ilya Enkovich
@ 2016-03-04 11:55 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2016-03-04 11:55 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: GCC Patches

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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-04 11:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-02 16:15 [PATCH, PR70026] Fix boolean comparison processing in masks conversion patterns Ilya Enkovich
2016-03-04 11:55 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).