diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2020-01-06 17:58:57 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2020-01-06 17:58:57 +0000 |
commit | 8a0ae3c130cd1e6beb0087a6967d33d8203f0dce (patch) | |
tree | af87d5ce5e1b70a6840cf92abbb0423c748f5c51 /gcc | |
parent | d54fc770768add469f646c20c0cab4e42510d895 (diff) | |
download | gcc-8a0ae3c130cd1e6beb0087a6967d33d8203f0dce.zip gcc-8a0ae3c130cd1e6beb0087a6967d33d8203f0dce.tar.gz gcc-8a0ae3c130cd1e6beb0087a6967d33d8203f0dce.tar.bz2 |
Check mask argument's type when vectorising conditional functions
We can't yet vectorise conditional internal functions whose boolean
condition is fed by a data access (or more generally, by a tree of logic
ops in which all the leaves are data accesses). Although we should add
that eventually, we'd need further work to generate good-quality code.
Unlike vectorizable_load and vectorizalbe_store, vectorizable_call
wasn't checking whether the mask had a suitable type, leading to an
ICE on the testcases.
2020-01-06 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* tree-vect-stmts.c (vect_check_load_store_mask): Rename to...
(vect_check_scalar_mask): ...this.
(vectorizable_store, vectorizable_load): Update call accordingly.
(vectorizable_call): Use vect_check_scalar_mask to check the mask
argument in calls to conditional internal functions.
gcc/testsuite/
* gcc.dg/vect/vect-cond-arith-8.c: New test.
* gcc.target/aarch64/sve/cond_fmul_5.c: Likewise.
From-SVN: r279907
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-cond-arith-8.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/sve/cond_fmul_5.c | 9 | ||||
-rw-r--r-- | gcc/tree-vect-stmts.c | 35 |
5 files changed, 46 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4ed0cd9..d72076f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2020-01-06 Richard Sandiford <richard.sandiford@arm.com> + + * tree-vect-stmts.c (vect_check_load_store_mask): Rename to... + (vect_check_scalar_mask): ...this. + (vectorizable_store, vectorizable_load): Update call accordingly. + (vectorizable_call): Use vect_check_scalar_mask to check the mask + argument in calls to conditional internal functions. + 2020-01-06 Andrew Stubbs <ams@codesourcery.com> * config/gcn/gcn-valu.md (subv64di3): Use separate alternatives for diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 425c0ce..3a6f6c6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-01-06 Richard Sandiford <richard.sandiford@arm.com> + + * gcc.dg/vect/vect-cond-arith-8.c: New test. + * gcc.target/aarch64/sve/cond_fmul_5.c: Likewise. + 2020-01-06 Nathan Sidwell <nathan@acm.org> PR c++/79592 diff --git a/gcc/testsuite/gcc.dg/vect/vect-cond-arith-8.c b/gcc/testsuite/gcc.dg/vect/vect-cond-arith-8.c new file mode 100644 index 0000000..e4b2abb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-cond-arith-8.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +void +f (float *x, _Bool *cond, float *y) +{ + for (int i = 0; i < 100; ++i) + x[i] = cond[i] ? y[i] * 100 : y[i]; +} diff --git a/gcc/testsuite/gcc.target/aarch64/sve/cond_fmul_5.c b/gcc/testsuite/gcc.target/aarch64/sve/cond_fmul_5.c new file mode 100644 index 0000000..c98bf3f --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/cond_fmul_5.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +void +f (float *x, _Bool *cond, float *y) +{ + for (int i = 0; i < 100; ++i) + x[i] = cond[i] ? y[i] * 100 : y[i]; +} diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 4da0042..0101d4c 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -2534,14 +2534,14 @@ get_load_store_type (stmt_vec_info stmt_info, tree vectype, bool slp, } /* Return true if boolean argument MASK is suitable for vectorizing - conditional load or store STMT_INFO. When returning true, store the type + conditional operation STMT_INFO. When returning true, store the type of the definition in *MASK_DT_OUT and the type of the vectorized mask in *MASK_VECTYPE_OUT. */ static bool -vect_check_load_store_mask (stmt_vec_info stmt_info, tree mask, - vect_def_type *mask_dt_out, - tree *mask_vectype_out) +vect_check_scalar_mask (stmt_vec_info stmt_info, tree mask, + vect_def_type *mask_dt_out, + tree *mask_vectype_out) { vec_info *vinfo = stmt_info->vinfo; if (!VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (mask))) @@ -3262,6 +3262,14 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, for (i = 0; i < nargs; i++) { op = gimple_call_arg (stmt, i); + + if ((int) i == mask_opno) + { + if (!vect_check_scalar_mask (stmt_info, op, &dt[i], &vectypes[i])) + return false; + continue; + } + if (!vect_is_simple_use (op, vinfo, &dt[i], &vectypes[i])) { if (dump_enabled_p ()) @@ -3270,11 +3278,6 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, return false; } - /* Skip the mask argument to an internal function. This operand - has been converted via a pattern if necessary. */ - if ((int) i == mask_opno) - continue; - /* We can only handle calls with arguments of the same type. */ if (rhs_type && !types_compatible_p (rhs_type, TREE_TYPE (op))) @@ -3544,12 +3547,6 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, continue; } - if (mask_opno >= 0 && !vectypes[mask_opno]) - { - gcc_assert (modifier != WIDEN); - vectypes[mask_opno] = truth_type_for (vectype_in); - } - for (i = 0; i < nargs; i++) { op = gimple_call_arg (stmt, i); @@ -7378,8 +7375,8 @@ vectorizable_store (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, if (mask_index >= 0) { mask = gimple_call_arg (call, mask_index); - if (!vect_check_load_store_mask (stmt_info, mask, &mask_dt, - &mask_vectype)) + if (!vect_check_scalar_mask (stmt_info, mask, &mask_dt, + &mask_vectype)) return false; } } @@ -8598,8 +8595,8 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, if (mask_index >= 0) { mask = gimple_call_arg (call, mask_index); - if (!vect_check_load_store_mask (stmt_info, mask, &mask_dt, - &mask_vectype)) + if (!vect_check_scalar_mask (stmt_info, mask, &mask_dt, + &mask_vectype)) return false; } } |