https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93538
Bug ID: 93538
Summary: equality of address of first member to address to
enclosing object not folded
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
The inequality below is trivially false but since GCC 4.6 the middle-end fails
to fold it into a constant (it is ultimately folded in RTL). In GCC 4.5 it was
folded by the ealias pass.
$ cat a.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout a.c
struct A { int a[1]; };
void f (struct A *p)
{
void *q = p->a;
if (p != q)
__builtin_abort ();
}
;; Function f (f, funcdef_no=0, decl_uid=1932, cgraph_uid=1, symbol_order=0)
f (struct A * p)
{
void * q;
<bb 2> [local count: 1073741824]:
q_2 = &p_1(D)->a;
if (p_1(D) != q_2)
goto <bb 3>; [0.00%]
else
goto <bb 4>; [100.00%]
<bb 3> [count: 0]:
__builtin_abort ();
<bb 4> [local count: 1073741824]:
return;
}