From: Jakub Jelinek <jakub@redhat.com>
To: Richard Biener <rguenther@suse.de>,
Ilya Enkovich <enkovich.gnu@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] Fix SLP wrong-code with VECTOR_BOOLEAN_TYPE_P (PR tree-optimization/71259)
Date: Fri, 03 Jun 2016 17:33:00 -0000 [thread overview]
Message-ID: <20160603173343.GM7387@tucnak.redhat.com> (raw)
In-Reply-To: <CAMbmDYaE0P0VEUu9mJT17SAZAtQhyFQ6VqPvS_-xjNqx9zGv0Q@mail.gmail.com>
On Tue, Jan 12, 2016 at 05:21:37PM +0300, Ilya Enkovich wrote:
> > --- gcc/tree-vect-slp.c.jj 2016-01-08 21:45:57.000000000 +0100
> > +++ gcc/tree-vect-slp.c 2016-01-11 12:07:19.633366712 +0100
> > @@ -2999,12 +2999,9 @@ vect_get_constant_vectors (tree op, slp_
> > gimple *init_stmt;
> > if (VECTOR_BOOLEAN_TYPE_P (vector_type))
> > {
> > - gcc_assert (fold_convertible_p (TREE_TYPE (vector_type),
> > - op));
> > + gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (op)));
> > init_stmt = gimple_build_assign (new_temp, NOP_EXPR, op);
>
> In vect_init_vector we had to introduce COND_EXPR to choose between 0 and -1 for
> boolean vectors. Shouldn't we do similar in SLP?
Apparently the answer to this is YES.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/6.2?
2016-06-03 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/71259
* tree-vect-slp.c (vect_get_constant_vectors): For
VECTOR_BOOLEAN_TYPE_P, return all ones constant instead of
one for constant op, and use COND_EXPR for non-constant.
* gcc.dg/vect/pr71259.c: New test.
--- gcc/tree-vect-slp.c.jj 2016-05-24 10:56:02.000000000 +0200
+++ gcc/tree-vect-slp.c 2016-06-03 17:01:12.740955935 +0200
@@ -3056,7 +3056,7 @@ vect_get_constant_vectors (tree op, slp_
if (integer_zerop (op))
op = build_int_cst (TREE_TYPE (vector_type), 0);
else if (integer_onep (op))
- op = build_int_cst (TREE_TYPE (vector_type), 1);
+ op = build_all_ones_cst (TREE_TYPE (vector_type));
else
gcc_unreachable ();
}
@@ -3071,8 +3071,14 @@ vect_get_constant_vectors (tree op, slp_
gimple *init_stmt;
if (VECTOR_BOOLEAN_TYPE_P (vector_type))
{
+ tree true_val
+ = build_all_ones_cst (TREE_TYPE (vector_type));
+ tree false_val
+ = build_zero_cst (TREE_TYPE (vector_type));
gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (op)));
- init_stmt = gimple_build_assign (new_temp, NOP_EXPR, op);
+ init_stmt = gimple_build_assign (new_temp, COND_EXPR,
+ op, true_val,
+ false_val);
}
else
{
--- gcc/testsuite/gcc.dg/vect/pr71259.c.jj 2016-06-03 17:05:37.693475438 +0200
+++ gcc/testsuite/gcc.dg/vect/pr71259.c 2016-06-03 17:05:32.418544731 +0200
@@ -0,0 +1,28 @@
+/* PR tree-optimization/71259 */
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+/* { dg-additional-options "-mavx" { target avx_runtime } } */
+
+#include "tree-vect.h"
+
+long a, b[1][44][2];
+long long c[44][17][2];
+
+int
+main ()
+{
+ int i, j, k;
+ check_vect ();
+ asm volatile ("" : : : "memory");
+ for (i = 0; i < 44; i++)
+ for (j = 0; j < 17; j++)
+ for (k = 0; k < 2; k++)
+ c[i][j][k] = (30995740 >= *(k + *(j + *b)) != (a != 8)) - 5105075050047261684;
+ asm volatile ("" : : : "memory");
+ for (i = 0; i < 44; i++)
+ for (j = 0; j < 17; j++)
+ for (k = 0; k < 2; k++)
+ if (c[i][j][k] != -5105075050047261684)
+ __builtin_abort ();
+ return 0;
+}
Jakub
next prev parent reply other threads:[~2016-06-03 17:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-11 17:13 [PATCH] Fix up my recent change to vect_get_constant_vectors (PR tree-optimization/69207) Jakub Jelinek
2016-01-12 14:21 ` Ilya Enkovich
2016-06-03 17:33 ` Jakub Jelinek [this message]
2016-06-06 8:06 ` [PATCH] Fix SLP wrong-code with VECTOR_BOOLEAN_TYPE_P (PR tree-optimization/71259) Richard Biener
2016-06-06 17:44 ` Jakub Jelinek
2016-06-07 7:13 ` Richard Biener
2016-06-07 9:23 ` Christophe Lyon
2016-06-07 9:28 ` Jakub Jelinek
2016-06-07 9:36 ` Ramana Radhakrishnan
2016-06-07 9:42 ` Jakub Jelinek
2016-06-07 12:43 ` Christophe Lyon
2016-06-07 12:47 ` Jakub Jelinek
2016-06-08 9:28 ` Christophe Lyon
2016-06-08 10:26 ` Richard Biener
2016-06-08 10:32 ` Jakub Jelinek
2016-06-08 10:33 ` Richard Biener
2016-06-08 14:44 ` Christophe Lyon
2016-06-08 14:50 ` Jakub Jelinek
2016-06-09 12:18 ` Christophe Lyon
2016-06-09 12:31 ` Jakub Jelinek
2016-06-09 12:40 ` Christophe Lyon
2016-06-09 12:46 ` Jakub Jelinek
2016-06-15 8:45 ` Christophe Lyon
2016-06-21 13:10 ` Christophe Lyon
2016-06-21 13:13 ` Jakub Jelinek
2016-06-21 13:46 ` Christophe Lyon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160603173343.GM7387@tucnak.redhat.com \
--to=jakub@redhat.com \
--cc=enkovich.gnu@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).