Commit 7251b0bf by Richard Sandiford Committed by Richard Sandiford

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  <richard.sandiford@linaro.org>

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
parent e009b055
2017-09-18 Richard Sandiford <richard.sandiford@linaro.org> 2017-09-18 Richard Sandiford <richard.sandiford@linaro.org>
* 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 <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>
......
2017-09-18 Richard Sandiford <richard.sandiford@linaro.org>
* gfortran.dg/vect/mask-store-1.f90: New test.
2017-09-18 Paolo Carlini <paolo.carlini@oracle.com> 2017-09-18 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/45033 PR c++/45033
......
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
...@@ -2331,7 +2331,8 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, ...@@ -2331,7 +2331,8 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
{ {
tree rhs = gimple_call_arg (stmt, 3); tree rhs = gimple_call_arg (stmt, 3);
vec_rhs = vect_get_vec_def_for_operand (rhs, stmt); 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. */ /* We should have catched mismatched types earlier. */
gcc_assert (useless_type_conversion_p (vectype, gcc_assert (useless_type_conversion_p (vectype,
TREE_TYPE (vec_rhs))); TREE_TYPE (vec_rhs)));
...@@ -2388,7 +2389,8 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, ...@@ -2388,7 +2389,8 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
if (i == 0) 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, dataref_ptr = vect_create_data_ref_ptr (stmt, vectype, NULL,
NULL_TREE, &dummy, gsi, NULL_TREE, &dummy, gsi,
&ptr_incr, false, &inv_p); &ptr_incr, false, &inv_p);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment