[Bug tree-optimization/104162] [12 Regression] Missed CSE after lowering of &MEM[ptr_1 + CST]
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jan 26 13:48:49 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104162
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #4)
> 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;
> }
Rather the following
struct S { int a[4]; };
int i;
int bar (struct S *p)
{
char *q = (char *)p + 4;
i = 1;
int *r = &((struct S *)p)->a[i];
return q == (char *)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.
The adjusted testcase is folded in forwprop after inlining which handles
p+4 == &p->a[1]
More information about the Gcc-bugs
mailing list