+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>
PR middle-end/89541
--- /dev/null
+! { 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
enum vect_def_type dt[4]
= { 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 ncopies, j;
auto_vec<tree, 8> vargs;
for (i = 0; i < nargs; i++)
{
- tree opvectype;
-
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 ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
rhs_type = TREE_TYPE (op);
if (!vectype_in)
- vectype_in = opvectype;
- else if (opvectype
- && opvectype != vectype_in)
+ vectype_in = vectypes[i];
+ else if (vectypes[i]
+ && vectypes[i] != vectype_in)
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
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++)
{
op = gimple_call_arg (stmt, i);
if (j == 0)
vec_oprnd0
- = vect_get_vec_def_for_operand (op, stmt_info);
+ = vect_get_vec_def_for_operand (op, stmt_info, vectypes[i]);
else
vec_oprnd0
= vect_get_vec_def_for_stmt_copy (vinfo, orig_vargs[i]);
if (j == 0)
{
vec_oprnd0
- = vect_get_vec_def_for_operand (op, stmt_info);
+ = vect_get_vec_def_for_operand (op, stmt_info,
+ vectypes[i]);
vec_oprnd1
= vect_get_vec_def_for_stmt_copy (vinfo, vec_oprnd0);
}