https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127876
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
I'll need to add tree_expr_maybe_real_zero_p, or rather a nice way to query
whether two values can be zeroes of different sign ...
Conservatively the following works, but it pessimizes -0.0 with initial value
of 1.0 for example.
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 02c3bf1d935..a19e6879021 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -7387,7 +7387,10 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
vect_is_simple_use (cond_initial_val, loop_vinfo, &cond_initial_dt);
if (cond_initial_dt == vect_constant_def
&& types_compatible_p (TREE_TYPE (cond_initial_val),
- TREE_TYPE (cond_reduc_val)))
+ TREE_TYPE (cond_reduc_val))
+ && (!SCALAR_FLOAT_TYPE_P (TREE_TYPE (cond_initial_val))
+ || (!tree_expr_maybe_real_minus_zero_p (cond_initial_val)
+ && !tree_expr_maybe_real_minus_zero_p (cond_reduc_val))))
{
tree e = fold_binary (LE_EXPR, boolean_type_node,
cond_initial_val, cond_reduc_val);
the alternative is to compare with both LT and GT and check the result
is different I guess.