--- /dev/null
+/* { dg-do run { target *-*-*gnu* } } */
+/* { dg-additional-options "-fno-tree-sink -fno-math-errno -ftree-vectorize -D_GNU_SOURCE" } */
+/* { dg-require-effective-target fenv_exceptions } */
+
+#include <fenv.h>
+
+double a[2];
+void __attribute__((noipa)) foo ()
+{
+ double x = a[0];
+ double y = a[1];
+ double norm = __builtin_sqrt (x*x + y*y);
+ if (norm > 1.)
+ {
+ x = x / norm;
+ y = y / norm;
+ }
+ a[0] = x;
+ a[1] = y;
+}
+
+int main()
+{
+ feenableexcept (FE_INVALID);
+ a[0] = 0.;
+ a[1] = 0.;
+ foo ();
+ if (a[0] != 0. || a[1] != 0.)
+ __builtin_abort ();
+ return 0;
+}
gcc_assert (seen_vector_def);
si = gsi_after_labels (as_a <bb_vec_info> (vinfo)->bbs[0]);
}
+ else if (is_a <bb_vec_info> (vinfo)
+ && gimple_bb (last_stmt) != gimple_bb (stmt_info->stmt)
+ && gimple_could_trap_p (stmt_info->stmt))
+ {
+ /* We've constrained possibly trapping operations to all come
+ from the same basic-block, if vectorized defs would allow earlier
+ scheduling still force vectorized stmts to the original block.
+ This is only necessary for BB vectorization since for loop vect
+ all operations are in a single BB and scalar stmt based
+ placement doesn't play well with epilogue vectorization. */
+ gcc_assert (dominated_by_p (CDI_DOMINATORS,
+ gimple_bb (stmt_info->stmt),
+ gimple_bb (last_stmt)));
+ si = gsi_after_labels (gimple_bb (stmt_info->stmt));
+ }
else if (is_a <gphi *> (last_stmt))
si = gsi_after_labels (gimple_bb (last_stmt));
else