This is a followup on the earlier RFC I sent in October. It implements a less restrictive variant by partitioning the clique set into problematic (have to remap on BB copy) and non-problematic ones. The single non-problematic one is where the scope of the restrict affected refs is the whole function (clique == 1) while all other cliques get introduced via inlining and subsequent copying of inlined blocks.
The first patch performs this partitioning, the second one will add the clique remapping on BB copying. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2019-02-22 Richard Biener <rguent...@suse.de> PR tree-optimization/87609 * tree-core.h (tree_base): Document special clique values. * tree-inline.c (remap_dependence_clique): Do not use the special clique value of one. (maybe_set_dependence_info): Use clique one. (clear_dependence_clique): New callback. (compute_dependence_clique): Clear clique one from all refs before assigning it (again). Index: gcc/tree-core.h =================================================================== --- gcc/tree-core.h (revision 269034) +++ gcc/tree-core.h (working copy) @@ -1032,7 +1032,9 @@ struct GTY(()) tree_base { expression trees and specify known data non-dependences. For two memory references in a function they are known to not alias if dependence_info.clique are equal and dependence_info.base - are distinct. */ + are distinct. Clique number zero means there is no information, + clique number one is populated from function global information + and thus needs no remapping on transforms like loop unrolling. */ struct { unsigned short clique; unsigned short base; Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 269034) +++ gcc/tree-inline.c (working copy) @@ -911,7 +911,12 @@ remap_dependence_clique (copy_body_data bool existed; unsigned short &newc = id->dependence_map->get_or_insert (clique, &existed); if (!existed) - newc = ++cfun->last_clique; + { + /* Clique 1 is reserved for local ones set by PTA. */ + if (cfun->last_clique == 0) + cfun->last_clique = 1; + newc = ++cfun->last_clique; + } return newc; } Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 269034) +++ gcc/tree-ssa-structalias.c (working copy) @@ -7495,7 +7495,11 @@ maybe_set_dependence_info (gimple *, tre if (MR_DEPENDENCE_CLIQUE (base) == 0) { if (clique == 0) - clique = ++cfun->last_clique; + { + if (cfun->last_clique == 0) + cfun->last_clique = 1; + clique = 1; + } if (restrict_var->ruid == 0) restrict_var->ruid = ++last_ruid; MR_DEPENDENCE_CLIQUE (base) = clique; @@ -7506,12 +7510,42 @@ maybe_set_dependence_info (gimple *, tre return false; } +/* Clear dependence info for the clique DATA. */ + +static bool +clear_dependence_clique (gimple *, tree base, tree, void *data) +{ + unsigned short clique = (uintptr_t)data; + if ((TREE_CODE (base) == MEM_REF + || TREE_CODE (base) == TARGET_MEM_REF) + && MR_DEPENDENCE_CLIQUE (base) == clique) + { + MR_DEPENDENCE_CLIQUE (base) = 0; + MR_DEPENDENCE_BASE (base) = 0; + } + + return false; +} + /* Compute the set of independend memory references based on restrict tags and their conservative propagation to the points-to sets. */ static void compute_dependence_clique (void) { + /* First clear the special "local" clique. */ + basic_block bb; + if (cfun->last_clique != 0) + FOR_EACH_BB_FN (bb, cfun) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); + !gsi_end_p (gsi); gsi_next (&gsi)) + { + gimple *stmt = gsi_stmt (gsi); + walk_stmt_load_store_ops (stmt, (void *)(uintptr_t) 1, + clear_dependence_clique, + clear_dependence_clique); + } + unsigned short clique = 0; unsigned short last_ruid = 0; bitmap rvars = BITMAP_ALLOC (NULL);