https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46032
--- Comment #10 from vries at gcc dot gnu.org --- An observation. A patch like this allows vectorization without alias check: ... diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 8290a65..501d631 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1241,7 +1241,12 @@ install_var_field (tree var, bool by_ref, int mask, omp_context *ctx) type = build_pointer_type (build_pointer_type (type)); } else if (by_ref) +#if 0 type = build_pointer_type (type); +#else + type = build_qualified_type (build_reference_type (type), + TYPE_QUAL_RESTRICT); +#endif else if ((mask & 3) == 1 && is_reference (var)) type = TREE_TYPE (type); ... The problem is that we don't have information at this point to decide between pointer and restrict reference. If var would be a scalar, we could use addr_taken to ensure that the var is not aliased. For arrays that doesn't work. If the c frontend would distinguish between: - element read: result[x], and - alias created: result, &result, &result[x] and store that in an alias_created property, we could use that property to decide between pointer and restrict reference. That would not fix the problem in general though, since that solution would already no longer work if the example was rewritten using pointers. I wonder if postponing omp_expand till after ealias would give us enough information to update the field reference types with a restrict tag (or not) at that point. [ Though I'm not sure if doing that update there would actually have the desired effect. ]