From: Richard Sandiford Date: Mon, 18 Sep 2017 15:32:01 +0000 (+0000) Subject: Fix vectorizable_mask_load_store handling of invariant masks X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7251b0bfbf09fae831bb5d3d2d7a311e9d37b398;p=gcc.git Fix vectorizable_mask_load_store handling of invariant masks vectorizable_mask_load_store was not passing the required mask type to vect_get_vec_def_for_operand. This doesn't matter for masks that are defined in the loop, since their STMT_VINFO_VECTYPE will be what we need anyway. But it's not possible to tell which mask type the caller needs when looking at an invariant scalar boolean. As the comment above the function says: In case OP is an invariant or constant, a new stmt that creates a vector def needs to be introduced. VECTYPE may be used to specify a required type for vector invariant. This fixes the attached testcase for SVE. 2017-09-18 Richard Sandiford gcc/ * tree-vect-stmts.c (vectorizable_mask_load_store): Pass mask_vectype to vect_get_vec_def_for_operand when getting the mask operand. gcc/testsuite/ * gfortran.dg/vect/mask-store-1.f90: New test. From-SVN: r252932 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9142af1bb06..70b73509c4e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-09-18 Richard Sandiford + + * tree-vect-stmts.c (vectorizable_mask_load_store): Pass mask_vectype + to vect_get_vec_def_for_operand when getting the mask operand. + 2017-09-18 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f2ad8a052ee..a4662844f84 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-09-18 Richard Sandiford + + * gfortran.dg/vect/mask-store-1.f90: New test. + 2017-09-18 Paolo Carlini PR c++/45033 diff --git a/gcc/testsuite/gfortran.dg/vect/mask-store-1.f90 b/gcc/testsuite/gfortran.dg/vect/mask-store-1.f90 new file mode 100644 index 00000000000..83cd8ddfea8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/vect/mask-store-1.f90 @@ -0,0 +1,11 @@ +subroutine foo(a, b, x, n) + real(kind=8) :: a(n), b(n), tmp + logical(kind=1) :: x + integer(kind=4) :: i, n + do i = 1, n + if (x) then + a(i) = b(i) + end if + b(i) = b(i) + 10 + end do +end subroutine diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 852e5cdf183..8f0d3d09096 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -2331,7 +2331,8 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, { tree rhs = gimple_call_arg (stmt, 3); vec_rhs = vect_get_vec_def_for_operand (rhs, stmt); - vec_mask = vect_get_vec_def_for_operand (mask, stmt); + vec_mask = vect_get_vec_def_for_operand (mask, stmt, + mask_vectype); /* We should have catched mismatched types earlier. */ gcc_assert (useless_type_conversion_p (vectype, TREE_TYPE (vec_rhs))); @@ -2388,7 +2389,8 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, if (i == 0) { - vec_mask = vect_get_vec_def_for_operand (mask, stmt); + vec_mask = vect_get_vec_def_for_operand (mask, stmt, + mask_vectype); dataref_ptr = vect_create_data_ref_ptr (stmt, vectype, NULL, NULL_TREE, &dummy, gsi, &ptr_incr, false, &inv_p);