Commit f2d040ab by Richard Sandiford Committed by Richard Sandiford

Fix mask type choice in vectorizable_call (PR 89535)

This is another case in which we were failing to pass the expected
mask vector type to vect_get_vec_def_for_operand.

2019-02-28  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	PR tree-optimization/89535
	* tree-vect-stmts.c (vectorizable_call): Record the vector types
	for each operand.  Calculate the fallback choice for mask operands
	and pass it to vect_get_vec_def_for_operand.

gcc/testsuite/
	PR tree-optimization/89535
	* gfortran.dg/vect/pr89535.f90: New test.

From-SVN: r269308
parent 22fe0312
2019-03-01 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/89535
* tree-vect-stmts.c (vectorizable_call): Record the vector types
for each operand. Calculate the fallback choice for mask operands
and pass it to vect_get_vec_def_for_operand.
2019-03-01 Richard Biener <rguenther@suse.de> 2019-03-01 Richard Biener <rguenther@suse.de>
PR middle-end/89541 PR middle-end/89541
......
2019-03-01 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/89535
* gfortran.dg/vect/pr89535.f90: New test.
2019-03-01 Richard Biener <rguenther@suse.de> 2019-03-01 Richard Biener <rguenther@suse.de>
PR middle-end/89541 PR middle-end/89541
......
! { dg-do compile }
subroutine foo(tmp1, tmp2, tmp3)
integer, parameter :: n = 100
real :: tmp1(n,2), tmp2(n), tmp3(n)
integer :: i, c1, c2, c3
logical :: cond
common c1, c2, c3
c2 = c3
cond = c1 .eq. 1 .and. c3 .eq. 1
do i = 1,100
if (cond) tmp2(i) = tmp1(i,1) / tmp1(i,2)
end do
do i = 1,100
if (cond) tmp3(i) = tmp2(i)
end do
end subroutine foo
...@@ -3123,6 +3123,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -3123,6 +3123,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
enum vect_def_type dt[4] enum vect_def_type dt[4]
= { vect_unknown_def_type, vect_unknown_def_type, vect_unknown_def_type, = { vect_unknown_def_type, vect_unknown_def_type, vect_unknown_def_type,
vect_unknown_def_type }; vect_unknown_def_type };
tree vectypes[ARRAY_SIZE (dt)] = {};
int ndts = ARRAY_SIZE (dt); int ndts = ARRAY_SIZE (dt);
int ncopies, j; int ncopies, j;
auto_vec<tree, 8> vargs; auto_vec<tree, 8> vargs;
...@@ -3182,10 +3183,8 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -3182,10 +3183,8 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {
tree opvectype;
op = gimple_call_arg (stmt, i); op = gimple_call_arg (stmt, i);
if (!vect_is_simple_use (op, vinfo, &dt[i], &opvectype)) if (!vect_is_simple_use (op, vinfo, &dt[i], &vectypes[i]))
{ {
if (dump_enabled_p ()) if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
...@@ -3211,9 +3210,9 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -3211,9 +3210,9 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
rhs_type = TREE_TYPE (op); rhs_type = TREE_TYPE (op);
if (!vectype_in) if (!vectype_in)
vectype_in = opvectype; vectype_in = vectypes[i];
else if (opvectype else if (vectypes[i]
&& opvectype != vectype_in) && vectypes[i] != vectype_in)
{ {
if (dump_enabled_p ()) if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
...@@ -3446,12 +3445,19 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -3446,12 +3445,19 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
continue; continue;
} }
if (mask_opno >= 0 && !vectypes[mask_opno])
{
gcc_assert (modifier != WIDEN);
vectypes[mask_opno]
= build_same_sized_truth_vector_type (vectype_in);
}
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {
op = gimple_call_arg (stmt, i); op = gimple_call_arg (stmt, i);
if (j == 0) if (j == 0)
vec_oprnd0 vec_oprnd0
= vect_get_vec_def_for_operand (op, stmt_info); = vect_get_vec_def_for_operand (op, stmt_info, vectypes[i]);
else else
vec_oprnd0 vec_oprnd0
= vect_get_vec_def_for_stmt_copy (vinfo, orig_vargs[i]); = vect_get_vec_def_for_stmt_copy (vinfo, orig_vargs[i]);
...@@ -3584,7 +3590,8 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -3584,7 +3590,8 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
if (j == 0) if (j == 0)
{ {
vec_oprnd0 vec_oprnd0
= vect_get_vec_def_for_operand (op, stmt_info); = vect_get_vec_def_for_operand (op, stmt_info,
vectypes[i]);
vec_oprnd1 vec_oprnd1
= vect_get_vec_def_for_stmt_copy (vinfo, vec_oprnd0); = vect_get_vec_def_for_stmt_copy (vinfo, vec_oprnd0);
} }
......
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