optabs.c (expand_binop): Attempt to reuse pseudos for duplicate non-volatile operands...
authorRoger Sayle <roger@eyesopen.com>
Wed, 4 Jun 2003 04:40:26 +0000 (04:40 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Wed, 4 Jun 2003 04:40:26 +0000 (04:40 +0000)
* optabs.c (expand_binop): Attempt to reuse pseudos for duplicate
non-volatile operands of binary operations.
(prepare_cmp_insn): Likewise.

From-SVN: r67417

gcc/ChangeLog
gcc/optabs.c

index 9b20061921ea96629bb088c1eabc55ce98382ab8..034d6cc7767f11c6b68250b34f995ba11b984589 100644 (file)
@@ -1,3 +1,9 @@
+2003-06-03  Roger Sayle  <roger@eyesopen.com>
+
+       * optabs.c (expand_binop): Attempt to reuse pseudos for duplicate
+       non-volatile operands of binary operations.
+       (prepare_cmp_insn): Likewise.
+
 2003-06-03  Roger Sayle  <roger@eyesopen.com>
 
        * varasm.c (force_const_mem): Handle alignment of constants not
index b59f89ca8c0d0a2c0730df46331ad96fa619eabb..171d13f2d6e26790ede0d8286319a9ae3aa00a34 100644 (file)
@@ -700,8 +700,17 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
 
   if (flag_force_mem)
     {
-      op0 = force_not_mem (op0);
-      op1 = force_not_mem (op1);
+      /* Load duplicate non-volatile operands once.  */
+      if (rtx_equal_p (op0, op1) && ! volatile_refs_p (op0))
+       {
+         op0 = force_not_mem (op0);
+         op1 = op0;
+       }
+      else
+       {
+         op0 = force_not_mem (op0);
+         op1 = force_not_mem (op1);
+       }
     }
 
   /* If subtracting an integer constant, convert this into an addition of
@@ -3587,8 +3596,17 @@ prepare_cmp_insn (px, py, pcomparison, size, pmode, punsignedp, purpose)
 
   if (mode != BLKmode && flag_force_mem)
     {
-      x = force_not_mem (x);
-      y = force_not_mem (y);
+      /* Load duplicate non-volatile operands once.  */
+      if (rtx_equal_p (x, y) && ! volatile_refs_p (x))
+       {
+         x = force_not_mem (x);
+         y = x;
+       }
+      else
+       {
+         x = force_not_mem (x);
+         y = force_not_mem (y);
+       }
     }
 
   /* If we are inside an appropriately-short loop and one operand is an