On 6/20/07 7:52 AM, Bokhanko, Andrey S wrote: > typedef struct { > int s1_m1; > int s1_m2; > } S1; > > void foo(S1 *p1, S1 *p2) { > p2->s1_m1 = p1->s1_m2 * 11; > /* If ansi-aliasing happens, this MUL shold be removed. */ > p2->s1_m1 = p1->s1_m2 * 11; > > return; > } > > with: > > gcc4 -c -O2 -fno-strict-aliasing test.c > > and the resulting assembly file had only one LOAD, one STORE and one > implementation of MUL. This optimization is only possible if compiler > able to prove independence between p2->s1_m1 and p1->s1_m2. I never > looked at gcc's internal dumps.
Structural analysis let's you prove that stores to fields m1 and m2 may never overlap. They're always at different offsets, even if p1 and p2 point to the same area.