new file mode 100644
@@ -0,0 +1,25 @@
+/* { dg-additional-options "-ffast-math -fno-unsafe-math-optimizations" } */
+
+#include "tree-vect.h"
+
+double __attribute__((noipa))
+foo (double *x, double *y, int n)
+{
+ double res = 0.;
+ for (int i = 0; i < n; ++i)
+ if (y[i] > 0.)
+ res += x[i];
+ else
+ res = 64.;
+ return res;
+}
+
+double y[16] = { 1., 1., 1., 1., 0., 1., 1., 1.,
+ 1., 1., 1., 1., 1., 1., 1., 1. };
+int main ()
+{
+ check_vect ();
+ if (foo (y, y, 16) != 64. + 11.)
+ abort ();
+ return 0;
+}
@@ -4163,15 +4163,19 @@ pop:
FOR_EACH_IMM_USE_STMT (op_use_stmt, imm_iter, op.ops[opi])
{
- /* In case of a COND_OP (mask, op1, op2, op1) reduction we might have
- op1 twice (once as definition, once as else) in the same operation.
- Allow this. */
+ /* In case of a COND_OP (mask, op1, op2, op1) reduction we should
+ have op1 twice (once as definition, once as else) in the same
+ operation. Enforce this. */
if (cond_fn_p && op_use_stmt == use_stmt)
{
gcall *call = as_a<gcall *> (use_stmt);
unsigned else_pos
= internal_fn_else_index (internal_fn (op.code));
-
+ if (gimple_call_arg (call, else_pos) != op.ops[opi])
+ {
+ fail = true;
+ break;
+ }
for (unsigned int j = 0; j < gimple_call_num_args (call); ++j)
{
if (j == else_pos)