tree-optimization/113693 - LC SSA and region VN

The following fixes LC SSA preserving with region VN which was broken
when availability checking was enhanced to treat not visited value
numbers as available.  The following makes sure to honor availability
data we put in place for LC SSA preserving instead.

	PR tree-optimization/113693
	* tree-ssa-sccvn.cc (rpo_elim::eliminate_avail): Honor avail
	data when available.

	* gcc.dg/pr113693.c: New testcase.
This commit is contained in:
Richard Biener 2024-02-01 09:18:47 +01:00
parent d85c17a2b6
commit b84f8a5e0a
2 changed files with 20 additions and 4 deletions

View file

@ -0,0 +1,13 @@
/* { dg-do compile { target bitint } } */
/* { dg-options "-O2 -fdbg-cnt=vect_loop:1" } */
_BitInt(837) g, h;
void
fn1(void)
{
for (; g; g++)
for (; h; h++)
;
}
/* { dg-message "dbgcnt" "" { target *-*-* } 0 } */

View file

@ -7723,12 +7723,15 @@ rpo_elim::eliminate_avail (basic_block bb, tree op)
if (SSA_NAME_IS_DEFAULT_DEF (valnum))
return valnum;
vn_ssa_aux_t valnum_info = VN_INFO (valnum);
/* See above. */
if (!valnum_info->visited)
return valnum;
vn_avail *av = valnum_info->avail;
if (!av)
return NULL_TREE;
{
/* See above. But when there's availability info prefer
what we recorded there for example to preserve LC SSA. */
if (!valnum_info->visited)
return valnum;
return NULL_TREE;
}
if (av->location == bb->index)
/* On tramp3d 90% of the cases are here. */
return ssa_name (av->leader);