--- /dev/null
+/* { dg-require-effective-target vect_float_strict } */
+
+#include "tree-vect.h"
+
+struct FOO {
+ double a;
+ double b;
+ double c;
+};
+
+double __attribute__((noipa))
+sum_8_foos(const struct FOO* foos)
+{
+ double sum = 0;
+
+ for (int i = 0; i < 8; ++i)
+ {
+ struct FOO foo = foos[i];
+
+ /* Need to use an in-order reduction here, preserving
+ the load permutation. */
+ sum += foo.a;
+ sum += foo.c;
+ sum += foo.b;
+ }
+
+ return sum;
+}
+
+int main()
+{
+ struct FOO foos[8];
+
+ check_vect ();
+
+ __builtin_memset (foos, 0, sizeof (foos));
+ foos[0].a = __DBL_MAX__;
+ foos[0].b = 5;
+ foos[0].c = -__DBL_MAX__;
+
+ if (sum_8_foos (foos) != 5)
+ __builtin_abort ();
+ return 0;
+}
vertices[idx].perm_out = perms.length () - 1;
}
- /* In addition to the above we have to mark outgoing permutes facing
- non-reduction graph entries that are not represented as to be
- materialized. */
+ /* We have to mark outgoing permutations facing non-associating-reduction
+ graph entries that are not represented as to be materialized. */
for (slp_instance instance : vinfo->slp_instances)
if (SLP_INSTANCE_KIND (instance) == slp_inst_kind_ctor)
{
vertices[SLP_INSTANCE_TREE (instance)->vertex].perm_in = 0;
vertices[SLP_INSTANCE_TREE (instance)->vertex].perm_out = 0;
}
+ else if (SLP_INSTANCE_KIND (instance) == slp_inst_kind_reduc_chain)
+ {
+ stmt_vec_info stmt_info
+ = SLP_TREE_REPRESENTATIVE (SLP_INSTANCE_TREE (instance));
+ stmt_vec_info reduc_info = info_for_reduction (vinfo, stmt_info);
+ if (needs_fold_left_reduction_p (TREE_TYPE
+ (gimple_get_lhs (stmt_info->stmt)),
+ STMT_VINFO_REDUC_CODE (reduc_info)))
+ {
+ unsigned int node_i = SLP_INSTANCE_TREE (instance)->vertex;
+ vertices[node_i].perm_in = 0;
+ vertices[node_i].perm_out = 0;
+ }
+ }
/* Propagate permutes along the graph and compute materialization points. */
bool changed;