From: Richard Biener Date: Wed, 30 Jan 2019 12:41:13 +0000 (+0000) Subject: re PR tree-optimization/89111 (wrong code at -O1 and above on x86_64-linux-gnu) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=79977c82ff9ef0a79229a57277feac3cbcc17a83;p=gcc.git re PR tree-optimization/89111 (wrong code at -O1 and above on x86_64-linux-gnu) 2019-01-30 Richard Biener PR tree-optimization/89111 * tree-ssa-loop-im.c (gather_mem_refs_stmt): Restrict canonicalization to appropriately sized access types. * gcc.dg/torture/pr89111.c: New testcase. From-SVN: r268388 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2e6f49e92ff..4962f473501 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-01-30 Richard Biener + + PR tree-optimization/89111 + * tree-ssa-loop-im.c (gather_mem_refs_stmt): Restrict + canonicalization to appropriately sized access types. + 2019-01-30 Jakub Jelinek PR c++/89105 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e41b4e2500c..3488fdd717f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,7 +1,11 @@ +2019-01-30 Richard Biener + + PR tree-optimization/89111 + * gcc.dg/torture/pr89111.c: New testcase. + 2019-01-30 Andrew Stubbs PR testsuite/88920 - * lib/target-supports.exp: Cache result. 2019-01-30 Jakub Jelinek diff --git a/gcc/testsuite/gcc.dg/torture/pr89111.c b/gcc/testsuite/gcc.dg/torture/pr89111.c new file mode 100644 index 00000000000..3f1d6d95bf5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr89111.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +struct __attribute__((packed)) A { int b : 24; } c[243], f; + +int d, e, g, j; + +__attribute__((noipa)) int +foo (int x) +{ + if (x != 0) + __builtin_abort (); + return 2; +} + +int +main () +{ + struct A h = f; + h.b = 0; + while (e++ < 3) + { + while (d++ < 3) + c[46].b ^= 9890739; + f = c[46] = h; + } + while (g++ < 9) + j = foo (c[g * 9 + j].b); + return 0; +} diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index d8a84402d4b..631dd9059ae 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -1472,6 +1472,11 @@ gather_mem_refs_stmt (struct loop *loop, gimple *stmt) && aor.max_size.is_constant (&max_size) && size == max_size && (size % BITS_PER_UNIT) == 0 + /* We're canonicalizing to a MEM where TYPE_SIZE specifies the + size. Make sure this is consistent with the extraction. */ + && poly_int_tree_p (TYPE_SIZE (TREE_TYPE (*mem))) + && known_eq (wi::to_poly_offset (TYPE_SIZE (TREE_TYPE (*mem))), + aor.size) && (mem_base = get_addr_base_and_unit_offset (aor.ref, &mem_off))) { hash = iterative_hash_expr (ao_ref_base (&aor), 0);