aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-01 07:23:20 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-01 07:23:20 +0000
commitcf249248b92f4118a146c9142de7b316f94cf069 (patch)
tree6bed2bf3b06c9d369498338d8237a89fd602fbd6
parent777d6746be21d45a2b9909ce91114a01eac5fd2b (diff)
PR rtl-optimization/19579
Backport from mainline 2005-01-26 Jakub Jelinek <jakub@redhat.com> * ifcvt.c (noce_try_cmove_arith): If emitting instructions to set up both A and B, see if they don't clobber registers the other expr uses. * gcc.c-torture/execute/20050124-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_3-branch@99056 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/ifcvt.c24
-rw-r--r--gcc/testsuite/ChangeLog6
3 files changed, 35 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 72c575b41b3..eabe6fe7d31 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2005-05-01 Roger Sayle <roger@eyesopen.com>
+
+ PR rtl-optimization/19579
+ Backport from mainline
+ 2005-01-26 Jakub Jelinek <jakub@redhat.com>
+ * ifcvt.c (noce_try_cmove_arith): If emitting instructions to set up
+ both A and B, see if they don't clobber registers the other expr uses.
+
2005-04-30 Gabriel Dos Reis <gdr@integrable-solutions.net>
PR 14884
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index cd936e7e775..31fa73b64fd 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -1082,6 +1082,7 @@ noce_try_cmove_arith (if_info)
rtx a = if_info->a;
rtx b = if_info->b;
rtx x = if_info->x;
+ rtx orig_a, orig_b;
rtx insn_a, insn_b;
rtx tmp, target;
int is_mem = 0;
@@ -1137,6 +1138,9 @@ noce_try_cmove_arith (if_info)
start_sequence ();
+ orig_a = a;
+ orig_b = b;
+
/* If either operand is complex, load it into a register first.
The best way to do this is to copy the original insn. In this
way we preserve any clobbers etc that the insn may have had.
@@ -1168,7 +1172,7 @@ noce_try_cmove_arith (if_info)
}
if (! general_operand (b, GET_MODE (b)))
{
- rtx set;
+ rtx set, last;
if (no_new_pseudos)
goto end_seq_and_fail;
@@ -1176,7 +1180,7 @@ noce_try_cmove_arith (if_info)
if (is_mem)
{
tmp = gen_reg_rtx (GET_MODE (b));
- tmp = emit_insn (gen_rtx_SET (VOIDmode, tmp, b));
+ tmp = gen_rtx_SET (VOIDmode, tmp, b);
}
else if (! insn_b
#if 0
@@ -1195,8 +1199,22 @@ noce_try_cmove_arith (if_info)
tmp = copy_rtx (insn_b);
set = single_set (tmp);
SET_DEST (set) = b;
- tmp = emit_insn (PATTERN (tmp));
+ tmp = PATTERN (tmp);
+ }
+
+ /* If insn to set up A clobbers any registers B depends on, try to
+ swap insn that sets up A with the one that sets up B. If even
+ that doesn't help, punt. */
+ last = get_last_insn ();
+ if (last && modified_in_p (orig_b, last))
+ {
+ tmp = emit_insn_before (tmp, get_insns ());
+ if (modified_in_p (orig_a, tmp))
+ goto end_seq_and_fail;
}
+ else
+ tmp = emit_insn (tmp);
+
if (recog_memoized (tmp) < 0)
goto end_seq_and_fail;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 99cbc98bf32..5620cfa280a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2005-05-01 Roger Sayle <roger@eyesopen.com>
+
+ PR rtl-optimization/19579
+ Backport from mainline
+ * gcc.c-torture/execute/20050124-1.c: New test.
+
2005-04-04 Gabriel Dos Reis <gdr@integrable-solutions.net>
PR c++/18644