--- trunk/gcc/tree-sra.c 2010/06/10 16:44:04 160560 +++ trunk/gcc/tree-sra.c 2010/06/10 16:49:09 160561 @@ -1689,9 +1689,10 @@ /* Build a subtree of accesses rooted in *ACCESS, and move the pointer in the linked list along the way. Stop when *ACCESS is NULL or the access pointed - to it is not "within" the root. */ + to it is not "within" the root. Return false iff some accesses partially + overlap. */ -static void +static bool build_access_subtree (struct access **access) { struct access *root = *access, *last_child = NULL; @@ -1706,24 +1707,32 @@ last_child->next_sibling = *access; last_child = *access; - build_access_subtree (access); + if (!build_access_subtree (access)) + return false; } + + if (*access && (*access)->offset < limit) + return false; + + return true; } /* Build a tree of access representatives, ACCESS is the pointer to the first - one, others are linked in a list by the next_grp field. Decide about scalar - replacements on the way, return true iff any are to be created. */ + one, others are linked in a list by the next_grp field. Return false iff + some accesses partially overlap. */ -static void +static bool build_access_trees (struct access *access) { while (access) { struct access *root = access; - build_access_subtree (&access); + if (!build_access_subtree (&access)) + return false; root->next_grp = access; } + return true; } /* Return true if expr contains some ARRAY_REFs into a variable bounded @@ -2062,9 +2071,7 @@ struct access *access; access = sort_and_splice_var_accesses (var); - if (access) - build_access_trees (access); - else + if (!access || !build_access_trees (access)) disqualify_candidate (var, "No or inhibitingly overlapping accesses."); }