diff mbox

Additional check for mask type in masked load/store vectorization

Message ID 20160310101255.GB3131@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich March 10, 2016, 10:12 a.m. UTC
Hi,

Curently when vectorizing masked load/store we don't check
mask and value have the same number of elements.  Usually
conversion patterns apply and we don't have such case but
conversion patterns may fail to properly determine mask
type and we shouldn't rely on it so hard. 

Unfortunately I couldn't make a small testcase where we fail
to determine mask type.  For me it happeneds when mixed C/Fortran
code was compiled with LTO and I had various scalar boolean types.

Bootstrapped and regtested on x86_64-pc-linux-gnu.  Ok for trunk
with no testcase?

Thanks,
Ilya
--
gcc/

2016-03-10  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* tree-vect-stmts.c (vectorizable_mask_load_store): Check mask
	has a proper number of elements.

Comments

Richard Biener March 10, 2016, 10:50 a.m. UTC | #1
On Thu, Mar 10, 2016 at 11:12 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> Curently when vectorizing masked load/store we don't check
> mask and value have the same number of elements.  Usually
> conversion patterns apply and we don't have such case but
> conversion patterns may fail to properly determine mask
> type and we shouldn't rely on it so hard.
>
> Unfortunately I couldn't make a small testcase where we fail
> to determine mask type.  For me it happeneds when mixed C/Fortran
> code was compiled with LTO and I had various scalar boolean types.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu.  Ok for trunk
> with no testcase?

Ok.

Richard.

> Thanks,
> Ilya
> --
> gcc/
>
> 2016-03-10  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
>         * tree-vect-stmts.c (vectorizable_mask_load_store): Check mask
>         has a proper number of elements.
>
>
> diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
> index 6ac273d..06b1ab7 100644
> --- a/gcc/tree-vect-stmts.c
> +++ b/gcc/tree-vect-stmts.c
> @@ -1742,7 +1742,8 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
>    if (!mask_vectype)
>      mask_vectype = get_mask_type_for_scalar_type (TREE_TYPE (vectype));
>
> -  if (!mask_vectype || !VECTOR_BOOLEAN_TYPE_P (mask_vectype))
> +  if (!mask_vectype || !VECTOR_BOOLEAN_TYPE_P (mask_vectype)
> +      || TYPE_VECTOR_SUBPARTS (mask_vectype) != TYPE_VECTOR_SUBPARTS (vectype))
>      return false;
>
>    if (is_store)
diff mbox

Patch

diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 6ac273d..06b1ab7 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -1742,7 +1742,8 @@  vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!mask_vectype)
     mask_vectype = get_mask_type_for_scalar_type (TREE_TYPE (vectype));
 
-  if (!mask_vectype || !VECTOR_BOOLEAN_TYPE_P (mask_vectype))
+  if (!mask_vectype || !VECTOR_BOOLEAN_TYPE_P (mask_vectype)
+      || TYPE_VECTOR_SUBPARTS (mask_vectype) != TYPE_VECTOR_SUBPARTS (vectype))
     return false;
 
   if (is_store)