https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67671
Bug ID: 67671 Summary: restrict pointer reference looses restrict Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- Consider test-case test.c: ... void f (int *__restrict__ &__restrict__ p) { *p = 1; } ... When compiling the test-case with g++ -O2, we find one clique/base annotation at ealias: ... void f(int* __restrict__&) (intD.9 * restrict & restrict pD.2252) { intD.9 * _3; # VUSE <.MEM_1(D)> # PT = nonlocal escaped _3 = MEM[(intD.9 * restrict &)p_2(D) clique 1 base 1]; # .MEM_4 = VDEF <.MEM_1(D)> *_3 = 1; ... If we write an equivalent example using a struct with pointer field instead: ... struct ps { int *__restrict__ p; } f (struct ps &__restrict__ ps) { *(ps.p) = 1; } ... we get two clique/base annotations at ealias (after fixing PR67666). I think the two examples are similar enough to expect two clique/base annotations at ealias for the first example. Using this demonstrator patch, we manage that: ... diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 94016b9..fa7108a 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -5684,6 +5684,9 @@ create_variable_info_for_1 (tree decl, const char *name) vi->fullsize = tree_to_uhwi (declsize); vi->size = vi->fullsize; vi->is_full_var = true; + if (POINTER_TYPE_P (TREE_TYPE (decl)) + && TYPE_RESTRICT (TREE_TYPE (decl))) + vi->only_restrict_pointers = 1; fieldstack.release (); return vi; } ...