The testcase below gets misscompiled at -O2. The alias info looks this way:
Dereferenced pointers xa, UID 1527, struct test1 *, symbol memory tag: SMT.4, default def: xa_4 xb, UID 1528, struct test2 *, symbol memory tag: SMT.5, default def: xb_3 Symbol memory tags SMT.4, UID 1547, struct test1, is addressable, is global, call clobbered, may aliases: { global } SMT.5, UID 1548, struct test2, is addressable, is global, call clobbered, may aliases: { global } The alias sets for SMT.4 and SMT.5 intersect, so everything looks OK here. However, access_can_touch_variable (correctly) determines that the dereferences of xa and xb cannot touch "global"; hence we create the following virual operands: # SMT.5_8 = V_MAY_DEF <SMT.5_7>; xb_3->sub.a = 1; # SMT.4_10 = V_MAY_DEF <SMT.4_9>; xa_4->a = 8; # VUSE <SMT.5_8>; D.1531_5 = xb_3->sub.a; The accesses to xa and xb appear to be independent, which leads to a misscompilation. struct test1 { int a; int b; }; struct test2 { float d; struct test1 sub; }; int global; int bla(struct test1 *xa, struct test2 *xb) { global = 1; xb->sub.a = 1; xa->a = 8; return xb->sub.a; } int main(void) { struct test2 pom; if (bla (&pom.sub, &pom) != 8) abort (); return 0; } -- Summary: Misscompilation due to alias analysis Product: gcc Version: 4.2.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rakdver at gcc dot gnu dot org GCC build triplet: i686-pc-linux GCC host triplet: i686-pc-linux GCC target triplet: i686-pc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29156