This fixes bogus path-based disambiguation of mismatched array shape accesses.
Bootstrap & regtest running on x86_64-unknown-linux-gnu. Honza, is this the correct place to detect this or were we not supposed to arrive there? Thanks, Richard. 2020-02-17 Richard Biener <rguent...@suse.de> PR tree-optimization/93586 * tree-ssa-alias.c (nonoverlapping_array_refs_p): Fail when we're obviously not looking at same-shaped array accesses. * gcc.dg/torture/pr93586.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr93586.c | 21 +++++++++++++++++++++ gcc/tree-ssa-alias.c | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr93586.c diff --git a/gcc/testsuite/gcc.dg/torture/pr93586.c b/gcc/testsuite/gcc.dg/torture/pr93586.c new file mode 100644 index 00000000000..e861bdcd78e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr93586.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fgimple" } */ + +int __GIMPLE(ssa) foo(int j) +{ + int c[1][10][1]; + int _1; + +__BB(2): + c[0][1][0] = 1; + c[0][1] = _Literal (int[1]) {}; + _1 = c[0][j_2(D)][0]; + return _1; +} + +int main() +{ + if (foo (1) != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index b8df66ac1f2..e7caf9bee77 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -1291,6 +1291,11 @@ nonoverlapping_array_refs_p (tree ref1, tree ref2) tree elmt_type1 = TREE_TYPE (TREE_TYPE (TREE_OPERAND (ref1, 0))); tree elmt_type2 = TREE_TYPE (TREE_TYPE (TREE_OPERAND (ref2, 0))); + /* If one element is an array but not the other there's an obvious + mismatch in dimensionality. */ + if ((TREE_CODE (elmt_type1) == ARRAY_TYPE) + != (TREE_CODE (elmt_type2) == ARRAY_TYPE)) + return -1; if (TREE_OPERAND (ref1, 3)) { -- 2.16.4