aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Zadeck <zadeck@gcc.gnu.org>2007-12-10 21:31:59 +0000
committerKenneth Zadeck <zadeck@gcc.gnu.org>2007-12-10 21:31:59 +0000
commitc8305c98510ac10855723216959cbca83182aeb8 (patch)
tree6b17aca629fb07f8dd1cd92489d1718c8d612fe2
parent030e2013b15ffb169b44f18f54bb6480372f4bb6 (diff)
downloadgcc-c8305c98510ac10855723216959cbca83182aeb8.zip
gcc-c8305c98510ac10855723216959cbca83182aeb8.tar.gz
gcc-c8305c98510ac10855723216959cbca83182aeb8.tar.bz2
[multiple changes]
2007-12-10 Kenneth Zadeck <zadeck@naturalbridge.com> PR rtl-optimization/34302 * auto-inc-dec.c (attempt_change): Change place where move is inserted. 2007-12-10 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/34302 * gcc.c-torture/execute/20071210-1.c: New test. From-SVN: r130751
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/auto-inc-dec.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20071210-1.c67
4 files changed, 83 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d9dbd49..e9dca61 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-12-10 Kenneth Zadeck <zadeck@naturalbridge.com>
+
+ PR rtl-optimization/34302
+ * auto-inc-dec.c (attempt_change): Change place where move is
+ inserted.
+
2007-12-10 Jakub Jelinek <jakub@redhat.com>
* dwarf2out.c (gen_array_type_die, gen_descr_array_type_die): For
diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c
index e59adab..2e2d047 100644
--- a/gcc/auto-inc-dec.c
+++ b/gcc/auto-inc-dec.c
@@ -550,7 +550,10 @@ attempt_change (rtx new_addr, rtx inc_reg)
switch (inc_insn.form)
{
case FORM_PRE_ADD:
- mov_insn = insert_move_insn_before (mem_insn.insn,
+ /* Replace the addition with a move. Do it at the location of
+ the addition since the operand of the addition may change
+ before the memory reference. */
+ mov_insn = insert_move_insn_before (inc_insn.insn,
inc_insn.reg_res, inc_insn.reg0);
move_dead_notes (mov_insn, inc_insn.insn, inc_insn.reg0);
@@ -673,7 +676,7 @@ try_merge (void)
}
/* Look to see if the inc register is dead after the memory
- reference. If it is do not do the combination. */
+ reference. If it is, do not do the combination. */
if (find_regno_note (last_insn, REG_DEAD, REGNO (inc_reg)))
{
if (dump_file)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 120d026..dfcb3b0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2007-12-10 Jakub Jelinek <jakub@redhat.com>
+ PR rtl-optimization/34302
+ * gcc.c-torture/execute/20071210-1.c: New test.
+
+2007-12-10 Jakub Jelinek <jakub@redhat.com>
+
PR c++/34395
* g++.dg/cpp0x/error1.C: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20071210-1.c b/gcc/testsuite/gcc.c-torture/execute/20071210-1.c
new file mode 100644
index 0000000..0d113c0
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20071210-1.c
@@ -0,0 +1,67 @@
+/* PR rtl-optimization/34302 */
+
+extern void abort (void);
+
+struct S
+{
+ int n1, n2, n3, n4;
+};
+
+__attribute__((noinline)) struct S
+foo (int x, int y, int z)
+{
+ if (x != 10 || y != 9 || z != 8)
+ abort ();
+ struct S s = { 1, 2, 3, 4 };
+ return s;
+}
+
+__attribute__((noinline)) void **
+bar (void **u, int *v)
+{
+ void **w = u;
+ int *s = v, x, y, z;
+ void **p, **q;
+ static void *l[] = { &&lab1, &&lab1, &&lab2, &&lab3, &&lab4 };
+
+ if (!u)
+ return l;
+
+ q = *w++;
+ goto *q;
+lab2:
+ p = q;
+ q = *w++;
+ x = s[2];
+ y = s[1];
+ z = s[0];
+ s -= 1;
+ struct S r = foo (x, y, z);
+ s[3] = r.n1;
+ s[2] = r.n2;
+ s[1] = r.n3;
+ s[0] = r.n4;
+ goto *q;
+lab3:
+ p = q;
+ q = *w++;
+ s += 1;
+ s[0] = 23;
+lab1:
+ goto *q;
+lab4:
+ return 0;
+}
+
+int
+main (void)
+{
+ void **u = bar ((void **) 0, (int *) 0);
+ void *t[] = { u[2], u[4] };
+ int s[] = { 7, 8, 9, 10, 11, 12 };
+ if (bar (t, &s[1]) != (void **) 0
+ || s[0] != 4 || s[1] != 3 || s[2] != 2 || s[3] != 1
+ || s[4] != 11 || s[5] != 12)
+ abort ();
+ return 0;
+}