tree-optimization/99880 - avoid vectorizing irrelevant PHI backedge defs

This adds a relevancy check before trying to set the vector def of
a backedge in an unvectorized PHI.

2021-04-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/99880
	* tree-vect-loop.c (maybe_set_vectorized_backedge_value): Only
	set vectorized defs of relevant PHIs.

	* gcc.dg/torture/pr99880.c: New testcase.
This commit is contained in:
Richard Biener 2021-04-06 13:20:44 +02:00
parent 671f9f5c0f
commit e5c170e080
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,22 @@
/* { dg-do compile } */
/* { dg-additional-options "-ftree-vectorize" } */
unsigned a;
int b, c, d, e;
void f() {
b = 5;
for (; b <= 51; b++)
;
unsigned int g = -8;
while (g) {
g += 5;
int h = 10;
do {
h -= a = 1;
for (; a; a++)
;
c *= c >= d >= b;
} while (h);
c -= e;
}
}

View File

@ -9148,6 +9148,7 @@ maybe_set_vectorized_backedge_value (loop_vec_info loop_vinfo,
if (gphi *phi = dyn_cast <gphi *> (USE_STMT (use_p)))
if (gimple_bb (phi)->loop_father->header == gimple_bb (phi)
&& (phi_info = loop_vinfo->lookup_stmt (phi))
&& STMT_VINFO_RELEVANT_P (phi_info)
&& VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (phi_info))
&& STMT_VINFO_REDUC_TYPE (phi_info) != FOLD_LEFT_REDUCTION
&& STMT_VINFO_REDUC_TYPE (phi_info) != EXTRACT_LAST_REDUCTION)