From: Richard Biener Date: Mon, 9 Nov 2020 12:55:11 +0000 (+0100) Subject: tree-optimization/97746 - fix order of mask precision computes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ec735bc7646500570d9d6e45ef335e6d547b1433;p=gcc.git tree-optimization/97746 - fix order of mask precision computes This fixes the order of walking PHIs and stmts for BB mask precision compute. 2020-11-09 Richard Biener PR tree-optimization/97746 * tree-vect-patterns.c (vect_determine_precisions): First walk PHIs. * gcc.dg/vect/bb-slp-pr97746.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr97746.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr97746.c new file mode 100644 index 00000000000..c5a615d1253 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr97746.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int a, b; +short c; + +extern void f (short*); + +void d() +{ + short e[2] = {0, 0}; + while (a) + { + f(e); + int g = 0 || a, h = 8 && c; + short i = c; + c = h & g; + if (b) + b = g || i; + } +} diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index eefa7cf6799..f68a87e05ed 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -5182,15 +5182,15 @@ vect_determine_precisions (vec_info *vinfo) for (unsigned i = 0; i < bb_vinfo->bbs.length (); ++i) { basic_block bb = bb_vinfo->bbs[i]; - for (auto gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (auto gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - stmt_vec_info stmt_info = vinfo->lookup_stmt (gsi_stmt (gsi)); + stmt_vec_info stmt_info = vinfo->lookup_stmt (gsi.phi ()); if (stmt_info && STMT_VINFO_VECTORIZABLE (stmt_info)) vect_determine_mask_precision (vinfo, stmt_info); } - for (auto gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (auto gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - stmt_vec_info stmt_info = vinfo->lookup_stmt (gsi.phi ()); + stmt_vec_info stmt_info = vinfo->lookup_stmt (gsi_stmt (gsi)); if (stmt_info && STMT_VINFO_VECTORIZABLE (stmt_info)) vect_determine_mask_precision (vinfo, stmt_info); }