+2018-01-23 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR tree-optimization/83965
+ * tree-vect-patterns.c (vect_reassociating_reduction_p): New function.
+ (vect_recog_dot_prod_pattern, vect_recog_sad_pattern): Use it
+ instead of checking only for a reduction.
+ (vect_recog_widen_sum_pattern): Likewise.
+
2018-01-23 Jan Hubicka <hubicka@ucw.cz>
* predict.c (probably_never_executed): Only use precise profile info.
+2018-01-23 Richard Sandiford <richard.sandiford@linaro.org>
+
+ PR tree-optimization/83965
+ * gcc.dg/vect/pr83965.c: New test.
+
2018-01-23 Richard Biener <rguenther@suse.de>
PR tree-optimization/83963
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-ftrapv" } */
+
+int
+mac (const short *a, const short *b, int sqr, int *sum)
+{
+ int i;
+ int dotp = *sum;
+
+ for (i = 0; i < 150; i++)
+ {
+ dotp += b[i] * a[i];
+ sqr += b[i] * b[i];
+ }
+
+ *sum = dotp;
+ return sqr;
+}
return make_temp_ssa_name (type, stmt, "patt");
}
+/* Return true if STMT_VINFO describes a reduction for which reassociation
+ is allowed. */
+
+static bool
+vect_reassociating_reduction_p (stmt_vec_info stmt_vinfo)
+{
+ return (STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_reduction_def
+ && STMT_VINFO_REDUC_TYPE (stmt_vinfo) != FOLD_LEFT_REDUCTION);
+}
+
/* Function vect_recog_dot_prod_pattern
Try to find the following pattern:
{
gimple *def_stmt;
- if (STMT_VINFO_DEF_TYPE (stmt_vinfo) != vect_reduction_def
+ if (!vect_reassociating_reduction_p (stmt_vinfo)
&& ! STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_vinfo))
return NULL;
oprnd0 = gimple_assign_rhs1 (last_stmt);
{
gimple *def_stmt;
- if (STMT_VINFO_DEF_TYPE (stmt_vinfo) != vect_reduction_def
+ if (!vect_reassociating_reduction_p (stmt_vinfo)
&& ! STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_vinfo))
return NULL;
plus_oprnd0 = gimple_assign_rhs1 (last_stmt);
if (gimple_assign_rhs_code (last_stmt) != PLUS_EXPR)
return NULL;
- if (STMT_VINFO_DEF_TYPE (stmt_vinfo) != vect_reduction_def
+ if (!vect_reassociating_reduction_p (stmt_vinfo)
&& ! STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_vinfo))
return NULL;