aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Dapp <rdapp@ventanamicro.com>2023-11-17 10:34:35 +0100
committerRobin Dapp <rdapp@ventanamicro.com>2023-11-20 10:21:58 +0100
commitf25a5b199a0ebd4695466e665e49041339f0c6a7 (patch)
tree2da9972bb2147ab80bc32d1c1e9147177102c861
parent103a3966bc7b68f91b6cd3c5beb330c4b8570c90 (diff)
downloadgcc-f25a5b199a0ebd4695466e665e49041339f0c6a7.zip
gcc-f25a5b199a0ebd4695466e665e49041339f0c6a7.tar.gz
gcc-f25a5b199a0ebd4695466e665e49041339f0c6a7.tar.bz2
vect: Add bool pattern handling for COND_OPs.
In order to handle masks properly for conditional operations this patch teaches vect_recog_mask_conversion_pattern to also handle conditional operations. Now we convert e.g. _mask = *_6; _ifc123 = COND_OP (_mask, ...); into _mask = *_6; patt200 = (<signed-boolean:1>) _mask; patt201 = COND_OP (patt200, ...); This way the mask will be properly recognized as boolean mask and the correct vector mask will be generated. gcc/ChangeLog: PR middle-end/112406 * tree-vect-patterns.cc (vect_recog_mask_conversion_pattern): Convert masks for conditional operations as well. gcc/testsuite/ChangeLog: * gfortran.dg/pr112406.f90: New test.
-rw-r--r--gcc/testsuite/gfortran.dg/pr112406.f9021
-rw-r--r--gcc/tree-vect-patterns.cc26
2 files changed, 39 insertions, 8 deletions
diff --git a/gcc/testsuite/gfortran.dg/pr112406.f90 b/gcc/testsuite/gfortran.dg/pr112406.f90
new file mode 100644
index 0000000..27e96df
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr112406.f90
@@ -0,0 +1,21 @@
+! { dg-do compile { target { aarch64-*-* || riscv*-*-* } } }
+! { dg-options "-Ofast -w -fprofile-generate" }
+! { dg-additional-options "-march=rv64gcv -mabi=lp64d" { target riscv*-*-* } }
+! { dg-additional-options "-march=armv8-a+sve" { target aarch64-*-* } }
+
+module brute_force
+ integer, parameter :: r=9
+ integer sudoku1(1, r)
+ contains
+subroutine brute
+integer l(r), u(r)
+ where(sudoku1(1, :) /= 1)
+ l = 1
+ u = 1
+ end where
+do i1 = 1, u(1)
+ do
+ end do
+ end do
+end
+end
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 7debe7f..696b70b 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -5830,7 +5830,8 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo,
tree rhs1_op0 = NULL_TREE, rhs1_op1 = NULL_TREE;
tree rhs1_op0_type = NULL_TREE, rhs1_op1_type = NULL_TREE;
- /* Check for MASK_LOAD ans MASK_STORE calls requiring mask conversion. */
+ /* Check for MASK_LOAD and MASK_STORE as well as COND_OP calls requiring mask
+ conversion. */
if (is_gimple_call (last_stmt)
&& gimple_call_internal_p (last_stmt))
{
@@ -5842,6 +5843,7 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo,
return NULL;
bool store_p = internal_store_fn_p (ifn);
+ bool load_p = internal_store_fn_p (ifn);
if (store_p)
{
int rhs_index = internal_fn_stored_value_index (ifn);
@@ -5856,15 +5858,21 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo,
vectype1 = get_vectype_for_scalar_type (vinfo, TREE_TYPE (lhs));
}
+ if (!vectype1)
+ return NULL;
+
tree mask_arg = gimple_call_arg (last_stmt, mask_argno);
tree mask_arg_type = integer_type_for_mask (mask_arg, vinfo);
- if (!mask_arg_type)
- return NULL;
- vectype2 = get_mask_type_for_scalar_type (vinfo, mask_arg_type);
+ if (mask_arg_type)
+ {
+ vectype2 = get_mask_type_for_scalar_type (vinfo, mask_arg_type);
- if (!vectype1 || !vectype2
- || known_eq (TYPE_VECTOR_SUBPARTS (vectype1),
- TYPE_VECTOR_SUBPARTS (vectype2)))
+ if (!vectype2
+ || known_eq (TYPE_VECTOR_SUBPARTS (vectype1),
+ TYPE_VECTOR_SUBPARTS (vectype2)))
+ return NULL;
+ }
+ else if (store_p || load_p)
return NULL;
tmp = build_mask_conversion (vinfo, mask_arg, vectype1, stmt_vinfo);
@@ -5883,7 +5891,9 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo,
lhs = vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL);
gimple_call_set_lhs (pattern_stmt, lhs);
}
- gimple_call_set_nothrow (pattern_stmt, true);
+
+ if (load_p || store_p)
+ gimple_call_set_nothrow (pattern_stmt, true);
pattern_stmt_info = vinfo->add_stmt (pattern_stmt);
if (STMT_VINFO_DATA_REF (stmt_vinfo))