This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Avoid integer vector used as a vector mask


On Fri, Dec 11, 2015 at 10:58 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> Currently when MASK_LOAD and MASK_STORE is vectorized we check
> scalar type of a mask but don't check its vector mask.  It means
> we may vectorize it when mask was just loaded from an array of
> booleans.  This happens e.g. for following test:
>
> SUBROUTINE TEST (x, y, z, mask, ims, ime)
>   IMPLICIT NONE
>   INTEGER ims, ime, i
>   LOGICAL mask (ims:ime)
>   REAL x(ims:ime), y(ims:ime), z(ims:ime)
>
>   DO 812 i=ims,ime
>      IF (mask(i)) x(i) = y(i) - z(i)
> 812  CONTINUE
>   END
>
> Produced GIMPLE:
>
>   vect__15.30_76 = MEM[base: _91, offset: 0B];
>   vect__17.32_80 = MASK_LOAD (vectp_y.33_78, 4B, vect__15.30_76);
>   vect__19.35_83 = MASK_LOAD (vectp_z.36_81, 4B, vect__15.30_76);
>   vect__20.38_84 = vect__17.32_80 - vect__19.35_83;
>   MASK_STORE (vectp_x.39_85, 4B, vect__15.30_76, vect__20.38_84);
>
> Loaded values don't have required all 0s and all 1s values and
> shouldn't be used as a mask.  This patch checks vector type of
> a mask used for MASK_LOAD and MASK_STORE.  Bootstrapped and
> regtested for x86_64-pc-linux-gnu.  OK for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> Ilya
> --
> gcc/
>
> 2015-12-11  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
>         * tree-vect-stmts.c (vectorizable_mask_load_store): Check
>         mask vectype.
>
>
> diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
> index 5377d15..abcd9a4 100644
> --- a/gcc/tree-vect-stmts.c
> +++ b/gcc/tree-vect-stmts.c
> @@ -1780,7 +1780,7 @@ 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)
> +  if (!mask_vectype || !VECTOR_BOOLEAN_TYPE_P (mask_vectype))
>      return false;
>
>    if (is_store)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]