new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_double } */
+
+double foo (int x, double *p)
+{
+ double res = p[0] + p[1];
+ double tem = p[0] / x;
+ if (x)
+ {
+ p[0] = tem;
+ p[1] /= x;
+ }
+ return res + tem;
+}
+
+/* We may not SLP vectorize the FP division because it can trap and it
+ is distributed between two basic-blocks. */
+/* { dg-final { scan-tree-dump "Build SLP failed: different BB for PHI or possibly trapping operation in _\[0-9\]+ = _\[0-9\]+ / _\[0-9\]+;" "slp2" } } */
@@ -1214,14 +1214,14 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
}
}
- if (phi_p
+ if ((phi_p || gimple_could_trap_p (stmt_info->stmt))
&& (gimple_bb (first_stmt_info->stmt)
!= gimple_bb (stmt_info->stmt)))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
"Build SLP failed: different BB for PHI "
- "in %G", stmt);
+ "or possibly trapping operation in %G", stmt);
/* Mismatch. */
continue;
}