tree-optimization/110777 - abnormals and recent PRE optimization

The following avoids propagating abnormals with the recent tweak
to look through PRE introduced copies between equal values.

	PR tree-optimization/110777
	* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_avail):
	Avoid propagating abnormals.

	* gcc.dg/pr110777.c: New testcase.
This commit is contained in:
Richard Biener 2023-07-24 08:55:11 +02:00
parent fb132cdfb2
commit 50b5feaa94
2 changed files with 25 additions and 1 deletions

View file

@ -0,0 +1,22 @@
/* { dg-do compile } */
/* { dg-options "-O3 -w" } */
void pm_message (int);
int *findOrAddBackgroundInPalette_palette_pnm;
static void findOrAddBackgroundInPalette(unsigned *paletteSizeP,
int *backgroundIndexP) {
if (*paletteSizeP) {
*backgroundIndexP = (*paletteSizeP)++;
pm_message(0);
}
pm_message(findOrAddBackgroundInPalette_palette_pnm[*backgroundIndexP]);
}
void computeColorMap(int *backgroundIndexP) {
unsigned paletteSize;
findOrAddBackgroundInPalette(&paletteSize, backgroundIndexP);
}
int main() {
unsigned backgroundIndex;
_setjmp();
computeColorMap(&backgroundIndex);
}

View file

@ -6608,7 +6608,9 @@ eliminate_dom_walker::eliminate_avail (basic_block, tree op)
if (gimple_assign_rhs_class (ass) == GIMPLE_SINGLE_RHS)
{
tree rhs1 = gimple_assign_rhs1 (ass);
if (CONSTANT_CLASS_P (rhs1) || TREE_CODE (rhs1) == SSA_NAME)
if (CONSTANT_CLASS_P (rhs1)
|| (TREE_CODE (rhs1) == SSA_NAME
&& !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)))
av = rhs1;
}
return av;