aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Earnshaw <rearnsha@arm.com>2003-06-06 17:19:06 +0000
committerRichard Earnshaw <rearnsha@gcc.gnu.org>2003-06-06 17:19:06 +0000
commit3a11ec8b5344520f07a639c4bd676e1124c919cc (patch)
tree96392c22e7f38eb3f9bb7ab19a5aeb2aa01fd0d8
parent7dc8b126ce1892db6c4380dff070c664ed3e225f (diff)
downloadgcc-3a11ec8b5344520f07a639c4bd676e1124c919cc.zip
gcc-3a11ec8b5344520f07a639c4bd676e1124c919cc.tar.gz
gcc-3a11ec8b5344520f07a639c4bd676e1124c919cc.tar.bz2
re PR target/11052 ([arm] noce_process_if_block() can loose REG_INC notes)
PR target/11052 * ifcvt.c (noce_process_if_block): Fail if the destination has side-effects. gcc.c-torture/execute/20030606-1.c: New. From-SVN: r67558
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/ifcvt.c9
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20030606-1.c27
4 files changed, 46 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f674788..5d04111 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2003-06-06 Richard Earnshaw <rearnsha@arm.com>
+
+ PR target/11052
+ * ifcvt.c (noce_process_if_block): Fail if the destination has
+ side-effects.
+
2003-06-06 Jason Merrill <jason@redhat.com>
* stmt.c (resolve_asm_operand_names): Rename from
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index baac041..8747906 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -1821,6 +1821,15 @@ noce_process_if_block (ce_info)
|| modified_between_p (x, PREV_INSN (if_info.cond_earliest), jump))
insn_b = set_b = NULL_RTX;
}
+
+ /* If x has side effects then only the if-then-else form is safe to
+ convert. But even in that case we would need to restore any notes
+ (such as REG_INC) at then end. That can be tricky if
+ noce_emit_move_insn expands to more than one insn, so disable the
+ optimization entirely for now if there are side effects. */
+ if (side_effects_p (x))
+ return FALSE;
+
b = (set_b ? SET_SRC (set_b) : x);
/* Only operate on register destinations, and even then avoid extending
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f14b689..470d696 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2003-06-06 Richard Earnshaw <rearnsha@arm.com>
+
+ gcc.c-torture/execute/20030606-1.c: New.
+
2003-06-06 Roger Sayle <roger@eyesopen.com>
* gcc.dg/builtins-2.c: Correct check-in of incorrect version.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20030606-1.c b/gcc/testsuite/gcc.c-torture/execute/20030606-1.c
new file mode 100644
index 0000000..51054d9
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20030606-1.c
@@ -0,0 +1,27 @@
+
+int * foo (int *x, int b)
+{
+
+ *(x++) = 55;
+ if (b)
+ *(x++) = b;
+
+ return x;
+}
+
+main()
+{
+ int a[5];
+
+ memset (a, 1, sizeof (a));
+
+ if (foo(a, 0) - a != 1 || a[0] != 55 || a[1] != a[4])
+ abort();
+
+ memset (a, 1, sizeof (a));
+
+ if (foo(a, 2) - a != 2 || a[0] != 55 || a[1] != 2)
+ abort();
+
+ exit (0);
+}