]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/19579 (-march=i686 generates a bogus program for x86*)
authorRoger Sayle <roger@eyesopen.com>
Sun, 1 May 2005 07:23:20 +0000 (07:23 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sun, 1 May 2005 07:23:20 +0000 (07:23 +0000)
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.

From-SVN: r99056

gcc/ChangeLog
gcc/ifcvt.c
gcc/testsuite/ChangeLog

index 72c575b41b3850cf4f5345bf277b8562a9cbdb49..eabe6fe7d316a67b3bf9597f1ac24efaf90a1f0e 100644 (file)
@@ -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
index cd936e7e77584be57f32145743192d0d5d3d57d0..31fa73b64fd38712cf775e8557b1f5d24c55d5ab 100644 (file)
@@ -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;
     }
index 99cbc98bf32e2defa379090caa45d283d183f48e..5620cfa280a46f3ee89f65727e093787087008b5 100644 (file)
@@ -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