------- Comment #22 from jakub at gcc dot gnu dot org 2007-08-24 16:16 ------- Not sure how, could I pass the buck to you then?
My thought was just that may_alias_p could for STRUCT_FIELD_TAG call ipa_type_escape_field_does_not_clobber (TREE_TYPE (SFT_PARENT_VAR (var)), TREE_TYPE (var)) (i.e. don't care about PTRs type, just say if that field's address wasn't ever taken that it can't alias. That would be similar to how alias.c uses this function (again, doesn't use the pointer type at all). Anyway, I found that current GCC 4.2 miscompiles following modified testcase (works with 4.1 and the trunk, though neither 4.1 nor 4.3 actually optimize bar function as they could). 4.2 optimizes bar and misoptimizes baz, by assuming *x = 4; will not clobber s.b. /* { dg-do run } */ /* { dg-options "-O2" } */ extern void abort (void); struct S { struct S *a; int b; float f; }; static struct S s; static int * __attribute__((noinline, const)) foo (void) { return &s.b; } float __attribute__((noinline)) bar (float *f) { s.f = 1.0; *f = 4.0; return s.f; } int __attribute__((noinline)) baz (int *x) { s.b = 1; *x = 4; return s.b; } int t (void) { float f = 8.0; return bar (&f) + baz (foo ()); } int main (void) { if (t () != 5) abort (); return 0; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33136