From 36e95a9e539a08275a0a6ef542a7fae5baa5710f Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 10 Jun 2020 15:16:23 +0200 Subject: [PATCH] tree-optimization/95576 - fix compare-debug issue with SLP vectorization The following avoids leading debug stmts in BB vectorizer regions. 2020-06-10 Richard Biener PR tree-optimization/95576 * tree-vect-slp.c (vect_slp_bb): Skip leading debug stmts. * g++.dg/vect/pr95576.cc: New testcase. --- gcc/testsuite/g++.dg/vect/pr95576.cc | 23 +++++++++++++++++++++++ gcc/tree-vect-slp.c | 9 ++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/vect/pr95576.cc diff --git a/gcc/testsuite/g++.dg/vect/pr95576.cc b/gcc/testsuite/g++.dg/vect/pr95576.cc new file mode 100644 index 00000000000..64e0e2dae7f --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr95576.cc @@ -0,0 +1,23 @@ +// { dg-do compile } +// { dg-additional-options "-O3 -fno-tree-forwprop -fcompare-debug" } + +struct S { + virtual ~S(); + struct S *s; + virtual void m(); + int f; + void *d; +}; + +struct T : S { + void m(); +}; + +S::~S() { + if (s) { + s->f = 0; + s->d = __null; + } +} + +void T::m() {} diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 0217a524f05..866ce8d3717 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -3316,7 +3316,12 @@ vect_slp_bb (basic_block bb) { gimple *stmt = gsi_stmt (gsi); if (is_gimple_debug (stmt)) - continue; + { + /* Skip leading debug stmts. */ + if (gsi_stmt (region_begin) == stmt) + gsi_next (®ion_begin); + continue; + } insns++; if (gimple_location (stmt) != UNKNOWN_LOCATION) @@ -3325,6 +3330,8 @@ vect_slp_bb (basic_block bb) if (!vect_find_stmt_data_reference (NULL, stmt, &datarefs)) break; } + if (gsi_end_p (region_begin)) + break; /* Skip leading unhandled stmts. */ if (gsi_stmt (region_begin) == gsi_stmt (gsi)) -- 2.30.2