From ec735bc7646500570d9d6e45ef335e6d547b1433 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 9 Nov 2020 13:55:11 +0100 Subject: [PATCH] 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. --- gcc/testsuite/gcc.dg/vect/bb-slp-pr97746.c | 20 ++++++++++++++++++++ gcc/tree-vect-patterns.c | 8 ++++---- 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr97746.c 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 0000000..c5a615d --- /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 eefa7cf..f68a87e 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); } -- 2.7.4