]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/19579 (-march=i686 generates a bogus program for x86*)
authorJakub Jelinek <jakub@redhat.com>
Thu, 10 Feb 2005 17:11:11 +0000 (18:11 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 10 Feb 2005 17:11:11 +0000 (18:11 +0100)
PR rtl-optimization/19579
* 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: r94835

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

index eb394b821812f8a39ca5619bd41c2bf94dc24393..19e4d7bd956bd1b6b0413f0fc3e57115275ef01c 100644 (file)
@@ -1,3 +1,9 @@
+2005-02-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/19579
+       * 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-02-08  Alan Modra  <amodra@bigpond.net.au>
 
        PR target/19803
index 640ab2cf2f9cf3b5e30a1a0836e18a9829618c39..b9a50387dc82e8450d8d9bd25c1a6c33eb118550 100644 (file)
@@ -1193,6 +1193,7 @@ noce_try_cmove_arith (struct noce_if_info *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;
@@ -1248,6 +1249,9 @@ noce_try_cmove_arith (struct noce_if_info *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.
@@ -1279,7 +1283,7 @@ noce_try_cmove_arith (struct noce_if_info *if_info)
     }
   if (! general_operand (b, GET_MODE (b)))
     {
-      rtx set;
+      rtx set, last;
 
       if (no_new_pseudos)
        goto end_seq_and_fail;
@@ -1287,9 +1291,7 @@ noce_try_cmove_arith (struct noce_if_info *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)
        goto end_seq_and_fail;
@@ -1299,8 +1301,22 @@ noce_try_cmove_arith (struct noce_if_info *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 d13ae5c6967446d693c432fd0f7392b76504f878..3f14579324c4994881b46408d926e61b03fdddbe 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/19579
+       * gcc.c-torture/execute/20050124-1.c: New test.
+
 2005-02-09  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/19787