From 6216f94e37db8de5a846c5945f4aa5f4e32aaedf Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 24 Apr 2009 08:58:02 +0200 Subject: re PR rtl-optimization/39794 (Miscompile with -O2 -funroll-loops) PR rtl-optimization/39794 * alias.c (canon_true_dependence): Add x_addr argument. * rtl.h (canon_true_dependence): Adjust prototype. * cse.c (check_dependence): Adjust canon_true_dependence callers. * cselib.c (cselib_invalidate_mem): Likewise. * gcse.c (compute_transp): Likewise. * dse.c (scan_reads_nospill): Likewise. (record_store, check_mem_read_rtx): Likewise. For non-const-or-frame addresses pass base->val_rtx as mem_addr, for const-or-frame addresses canon_base_addr of the group, plus optional offset. (struct group_info): Rename canon_base_mem to canon_base_addr. (get_group_info): Set canon_base_addr to canon_rtx of base, not canon_rtx of base_mem. * gcc.dg/pr39794.c: New test. From-SVN: r146669 --- gcc/testsuite/gcc.dg/pr39794.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr39794.c (limited to 'gcc/testsuite/gcc.dg/pr39794.c') diff --git a/gcc/testsuite/gcc.dg/pr39794.c b/gcc/testsuite/gcc.dg/pr39794.c new file mode 100644 index 0000000..2702ba7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr39794.c @@ -0,0 +1,33 @@ +/* PR rtl-optimization/39794 */ +/* { dg-do run } */ +/* { dg-options "-O2 -funroll-loops" } */ + +extern void abort (); + +void +foo (int *a, int n) +{ + int i; + for (i = 0; i < n; i++) + { + a[i] *= 2; + a[i + 1] = a[i - 1] + a[i - 2]; + } +} + +int a[16]; +int ref[16] = { 0, 1, 4, 2, 10, 12, 24, 44, + 72, 136, 232, 416, 736, 1296, 2304, 2032 }; + +int +main () +{ + int i; + for (i = 0; i < 16; i++) + a[i] = i; + foo (a + 2, 16 - 3); + for (i = 0; i < 16; i++) + if (ref[i] != a[i]) + abort (); + return 0; +} -- cgit v1.1