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  <rguenther@suse.de>

	PR tree-optimization/95576
	* tree-vect-slp.c (vect_slp_bb): Skip leading debug stmts.

	* g++.dg/vect/pr95576.cc: New testcase.
This commit is contained in:
Richard Biener 2020-06-10 15:16:23 +02:00
parent b5cebc9ab7
commit 36e95a9e53
2 changed files with 31 additions and 1 deletions

View File

@ -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() {}

View File

@ -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 (&region_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))