http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47365
Summary: [4.5 Regression] wrong code with -O -ftree-pre Product: gcc Version: 4.5.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: zso...@seznam.cz Host: x86_64-pc-linux-gnu Target: x86_64-pc-linux-gnu Created attachment 23035 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23035 reduced testcase Reported by Vegard Nossum at IRC. Output: $ gcc-4.5 -O -ftree-pre testcase.c $ ./a.out Aborted In the testcase.c.092t.pre dump, there is: ... <bb 2>: D.2739_4 = b.a[0].i; i.0_5 = i; if (D.2739_4 != i.0_5) goto <bb 3>; else goto <bb 4>; <bb 3>: b.a[0] = b.a[1]; b.a[1].i = D.2739_4; pretmp.3_6 = b.a[1].i; goto <bb 6>; <bb 4>: ... <bb 9>: <bb 6>: # prephitmp.4_8 = PHI <D.2739_4(9), pretmp.3_6(3)> D.2739_9 = prephitmp.4_8; D.2739_9 = prephitmp.4_8; if (D.2739_9 == 0) goto <bb 7>; ... Problematic line is pretmp.3_6 = b.a[1].i; which reads the new value of "b.a[1].i". It should either happen one line earlier, or it should read "b.a[0].i". It seems that the fact "b.a[0] = b.a[1]" overwrites "b.a[0].i" is ignored. Of couse I can be wrong. Tested revisions: r169006 - OK 4.5 r168785 - fail 4.4 r168785 - OK