public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-5364] middle-end/97579 - lower VECTOR_BOOLEAN_TYPE_P VEC_COND_EXPRs
@ 2020-11-25 14:01 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2020-11-25 14:01 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:fddc7f0080f1f056c4d145451608ebd3e807422a
commit r11-5364-gfddc7f0080f1f056c4d145451608ebd3e807422a
Author: Richard Biener <rguenther@suse.de>
Date: Wed Nov 25 12:31:54 2020 +0100
middle-end/97579 - lower VECTOR_BOOLEAN_TYPE_P VEC_COND_EXPRs
This makes sure to lower VECTOR_BOOLEAN_TYPE_P typed non-vector
mode VEC_COND_EXPRs so we don't try to use vcond to expand those.
That's required for x86 and gcn integer mode boolean vectors.
2020-11-25 Richard Biener <rguenther@suse.de>
PR middle-end/97579
* gimple-isel.cc (gimple_expand_vec_cond_expr): Lower
VECTOR_BOOLEAN_TYPE_P, non-vector mode VEC_COND_EXPRs.
* gcc.dg/pr97579.c: New testcase.
Diff:
---
gcc/gimple-isel.cc | 22 ++++++++++++++++++++--
gcc/testsuite/gcc.dg/pr97579.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc
index b5362cc4b01..83281c0cbf9 100644
--- a/gcc/gimple-isel.cc
+++ b/gcc/gimple-isel.cc
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-ssa-dce.h"
#include "memmodel.h"
#include "optabs.h"
+#include "gimple-fold.h"
/* Expand all ARRAY_REF(VIEW_CONVERT_EXPR) gimple assignments into calls to
internal function based on vector type of selected expansion.
@@ -134,6 +135,25 @@ gimple_expand_vec_cond_expr (gimple_stmt_iterator *gsi,
lhs = gimple_assign_lhs (stmt);
machine_mode mode = TYPE_MODE (TREE_TYPE (lhs));
+ /* Lower mask typed, non-vector mode VEC_COND_EXPRs to bitwise operations.
+ Those can end up generated by folding and at least for integer mode masks
+ we cannot expect vcond expanders to exist. We lower a ? b : c
+ to (b & a) | (c & ~a). */
+ if (!VECTOR_MODE_P (mode))
+ {
+ gcc_assert (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (lhs))
+ && types_compatible_p (TREE_TYPE (op0), TREE_TYPE (op1)));
+ gimple_seq stmts = NULL;
+ tree type = TREE_TYPE (lhs);
+ location_t loc = gimple_location (stmt);
+ tree tem0 = gimple_build (&stmts, loc, BIT_AND_EXPR, type, op1, op0);
+ tree tem1 = gimple_build (&stmts, loc, BIT_NOT_EXPR, type, op0);
+ tree tem2 = gimple_build (&stmts, loc, BIT_AND_EXPR, type, op2, tem1);
+ tree tem3 = gimple_build (&stmts, loc, BIT_IOR_EXPR, type, tem0, tem2);
+ gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
+ return gimple_build_assign (lhs, tem3);
+ }
+
gcc_assert (!COMPARISON_CLASS_P (op0));
if (TREE_CODE (op0) == SSA_NAME)
{
@@ -198,7 +218,6 @@ gimple_expand_vec_cond_expr (gimple_stmt_iterator *gsi,
cmp_op_mode = TYPE_MODE (TREE_TYPE (op0a));
unsignedp = TYPE_UNSIGNED (TREE_TYPE (op0a));
-
gcc_assert (known_eq (GET_MODE_NUNITS (mode),
GET_MODE_NUNITS (cmp_op_mode)));
@@ -246,7 +265,6 @@ gimple_expand_vec_exprs (void)
{
gimple *g = gimple_expand_vec_cond_expr (&gsi,
&vec_cond_ssa_name_uses);
-
if (g != NULL)
{
tree lhs = gimple_assign_lhs (gsi_stmt (gsi));
diff --git a/gcc/testsuite/gcc.dg/pr97579.c b/gcc/testsuite/gcc.dg/pr97579.c
new file mode 100644
index 00000000000..5cd5427a528
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr97579.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 --param=max-unswitch-insns=1024" } */
+/* { dg-additional-options "-mavx512vl" { target x86_64-*-* i?86-*-* } } */
+
+int bad_odd_rows_0_0, rows_bad_row1, rows_bad_group_okay, calc_rows_row2;
+
+int
+rows_bad() {
+ int i, in_zeroes;
+ char block;
+ i = 0;
+ for (; i < 5; i++)
+ if (rows_bad_row1 & i)
+ in_zeroes = 0;
+ else {
+ if (!in_zeroes)
+ in_zeroes = 1;
+ if (block & 1)
+ rows_bad_group_okay = 1;
+ }
+ if (in_zeroes)
+ return rows_bad_group_okay;
+}
+
+void
+calc_rows() {
+ for (; calc_rows_row2; calc_rows_row2++) {
+ rows_bad();
+ bad_odd_rows_0_0 = rows_bad();
+ }
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-25 14:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 14:01 [gcc r11-5364] middle-end/97579 - lower VECTOR_BOOLEAN_TYPE_P VEC_COND_EXPRs 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).