[Bug tree-optimization/47621] New: Missed dependencies in address-taken optimization
uweigand at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Feb 6 16:03:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47621
Summary: Missed dependencies in address-taken optimization
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: uweigand@gcc.gnu.org
CC: rguenther@suse.de
The following program is mis-optimized with 4.6 (not earlier versions) at -O or
higher optimization levels:
int
main (void)
{
int data = 1;
struct ptr
{
int val;
} *ptr = (struct ptr *) &data;
ptr->val = 0;
return data;
}
This program should return 0, but actually returns 1.
After the "address-taken" optimization pass, we have:
dataD.1975_4 = 1;
MEM[(struct ptr *)&dataD.1975].valD.1977 = 0;
D.3453_2 = dataD.1975_4;
return D.3453_2;
so the dependency between the assignment to ptr->val and the use of data is
lost.
See this post for more information:
http://gcc.gnu.org/ml/gcc/2011-02/msg00079.html
H.J. Lu identified the following patch as introducing the regression:
http://gcc.gnu.org/ml/gcc-patches/2010-10/msg00788.html
More information about the Gcc-bugs
mailing list