The testcase from PR32921 shows that we end up with an alias set of zero for real8[0:] because in both functions this type is used in casts. When the first function is gimplified the gimplifier asks if the cast is a useless type conversion which in turn calls get_alias_set which sets the alias set. Once the second function is lowered to GIMPLE, the array-type gets re-built using build_array_type which calls layout_type:
if (!COMPLETE_TYPE_P (t)) layout_type (t); [because the type looks incomplete] which in turn globally re-sets the alias set to zero /* If an alias set has been set for this aggregate when it was incomplete, force it into alias set 0. This is too conservative, but we cannot call record_component_aliases here because some frontends still change the aggregates after layout_type. */ if (AGGREGATE_TYPE_P (type) && TYPE_ALIAS_SET_KNOWN_P (type)) TYPE_ALIAS_SET (type) = 0; } causing effectively wrong gimplification of the first function and pessimizatio of alias analysis. -- Summary: gimplification before build_array_type re-set alias set of arrays to zero Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: wrong-code, missed-optimization Severity: blocker Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rguenth at gcc dot gnu dot org OtherBugsDependingO 32921 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33816