public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR68286] Fix vector comparison expand
@ 2015-11-12  9:58 Ilya Enkovich
  2015-11-12 11:24 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Ilya Enkovich @ 2015-11-12  9:58 UTC (permalink / raw)
  To: gcc-patches

Hi,

My vector comparison patches broken expand of vector comparison on targets which don't have new comparison patterns but support VEC_COND_EXPR.  This happens because it's not checked vector comparison may be expanded as a comparison.  This patch fixes it.  Bootstrapped and regtested on powerpc64le-unknown-linux-gnu.  OK for trunk?

Thanks,
Ilya
--
gcc/

2015-11-12  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* expr.c (do_store_flag): Expand vector comparison as
	VEC_COND_EXPR if vector comparison is not supported
	by target.

gcc/testsuite/

2015-11-12  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* gcc.dg/pr68286.c: New test.


diff --git a/gcc/expr.c b/gcc/expr.c
index 03936ee..bd43dc4 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -11128,7 +11128,8 @@ do_store_flag (sepops ops, rtx target, machine_mode mode)
   if (TREE_CODE (ops->type) == VECTOR_TYPE)
     {
       tree ifexp = build2 (ops->code, ops->type, arg0, arg1);
-      if (VECTOR_BOOLEAN_TYPE_P (ops->type))
+      if (VECTOR_BOOLEAN_TYPE_P (ops->type)
+	  && expand_vec_cmp_expr_p (TREE_TYPE (arg0), ops->type))
 	return expand_vec_cmp_expr (ops->type, ifexp, target);
       else
 	{
diff --git a/gcc/testsuite/gcc.dg/pr68286.c b/gcc/testsuite/gcc.dg/pr68286.c
new file mode 100644
index 0000000..d0392e8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr68286.c
@@ -0,0 +1,17 @@
+/* PR target/68286 */
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+int a, b, c;
+int fn1 ()
+{
+  int d[] = {0};
+  for (; c; c++)
+    {
+      float e = c;
+      if (e)
+        d[0]++;
+    }
+  b = d[0];
+  return a;
+}

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

* Re: [PATCH, PR68286] Fix vector comparison expand
  2015-11-12  9:58 [PATCH, PR68286] Fix vector comparison expand Ilya Enkovich
@ 2015-11-12 11:24 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2015-11-12 11:24 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: GCC Patches

On Thu, Nov 12, 2015 at 10:57 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> My vector comparison patches broken expand of vector comparison on targets which don't have new comparison patterns but support VEC_COND_EXPR.  This happens because it's not checked vector comparison may be expanded as a comparison.  This patch fixes it.  Bootstrapped and regtested on powerpc64le-unknown-linux-gnu.  OK for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> Ilya
> --
> gcc/
>
> 2015-11-12  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
>         * expr.c (do_store_flag): Expand vector comparison as
>         VEC_COND_EXPR if vector comparison is not supported
>         by target.
>
> gcc/testsuite/
>
> 2015-11-12  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
>         * gcc.dg/pr68286.c: New test.
>
>
> diff --git a/gcc/expr.c b/gcc/expr.c
> index 03936ee..bd43dc4 100644
> --- a/gcc/expr.c
> +++ b/gcc/expr.c
> @@ -11128,7 +11128,8 @@ do_store_flag (sepops ops, rtx target, machine_mode mode)
>    if (TREE_CODE (ops->type) == VECTOR_TYPE)
>      {
>        tree ifexp = build2 (ops->code, ops->type, arg0, arg1);
> -      if (VECTOR_BOOLEAN_TYPE_P (ops->type))
> +      if (VECTOR_BOOLEAN_TYPE_P (ops->type)
> +         && expand_vec_cmp_expr_p (TREE_TYPE (arg0), ops->type))
>         return expand_vec_cmp_expr (ops->type, ifexp, target);
>        else
>         {
> diff --git a/gcc/testsuite/gcc.dg/pr68286.c b/gcc/testsuite/gcc.dg/pr68286.c
> new file mode 100644
> index 0000000..d0392e8
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr68286.c
> @@ -0,0 +1,17 @@
> +/* PR target/68286 */
> +/* { dg-do compile } */
> +/* { dg-options "-O3" } */
> +
> +int a, b, c;
> +int fn1 ()
> +{
> +  int d[] = {0};
> +  for (; c; c++)
> +    {
> +      float e = c;
> +      if (e)
> +        d[0]++;
> +    }
> +  b = d[0];
> +  return a;
> +}

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

end of thread, other threads:[~2015-11-12 11:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12  9:58 [PATCH, PR68286] Fix vector comparison expand Ilya Enkovich
2015-11-12 11:24 ` 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).