https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41898
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- Same for int * __restrict__ *a; int * __restrict__ *b; extern void link_error (void); int main() { a[0][0] = 0; b[0][0] = 1; if (a[0][0] != 0) link_error (); return 0; } the restrict-ness is attached to specific variable infos in PTA but here the restrict pointers fall out from a dereference op which might be present multiple times but would all need to pick up the same artificial restrict varinfo. That's currently not supported in the data structures and/or the constraint system and/or the graph solving. For the int * __restrict__ a[1] case we fail to recognize it in /* Mark global restrict qualified pointers. */ if ((POINTER_TYPE_P (TREE_TYPE (decl)) && TYPE_RESTRICT (TREE_TYPE (decl))) || vi->only_restrict_pointers) { and vi->only_restrict_pointers is only ever set for aggregates which we track field-wise (which arrays are not). Possible fix below - it wouldn't handle int * __restrict a[2] optimally since a[0] and a[1] would still alias. diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 416a26c996c..dcc7fafc4b9 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -6128,8 +6128,11 @@ create_variable_info_for_1 (tree decl, const char *name, bool add_id, vi->fullsize = tree_to_uhwi (declsize); vi->size = vi->fullsize; vi->is_full_var = true; - if (POINTER_TYPE_P (decl_type) - && (TYPE_RESTRICT (decl_type) || add_restrict)) + if ((POINTER_TYPE_P (decl_type) + && (TYPE_RESTRICT (decl_type) || add_restrict)) + || (TREE_CODE (decl_type) == ARRAY_TYPE + && POINTER_TYPE_P (TREE_TYPE (decl_type)) + && TYPE_RESTRICT (TREE_TYPE (decl_type)))) vi->only_restrict_pointers = 1; if (vi->only_restrict_pointers && !type_contains_placeholder_p (TREE_TYPE (decl_type))