https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104162
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Btw, in VN it would be nice to handle
struct S { int i; };
int i;
int bar (char *p)
{
char *q = p + 1;
i = 1;
char *r = (char *)&(((struct S *)&p[i])->i);
return q == r;
}
the main issue here is that this is vn_reference vs. vn_nary handling and this
transitions from vn_reference to possibly vn_nary with valueization. For VN
&MEM[p + 1] was more canonical and we could go back to this when seeing
pointer-plus -- at least when lookup & simplification does not produce a
redundancy.
Handling this in VN only and only when inlining is complete might also avoid
regressing the testcase again.