* expr.c (expand_expr <PLUS_EXPR>): Let expand_operands call
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 11 Oct 2003 21:00:51 +0000 (21:00 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 11 Oct 2003 21:00:51 +0000 (21:00 +0000)
safe_from_p for us, once it chooses an evaluation order.
(expand_expr <MULT_EXPR>): Likewise.
(expand_expr <MIN_EXPR> <MAX_EXPR>): Likewise.  If expand_operands
places the second operand in "target", swap the operands.
(do_store_flag): Let expand_operands call safe_from_p for us.

* gcc.c-torture/execute/20031011-1.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72376 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20031011-1.c [new file with mode: 0644]

index 8a7ff97..38bd51f 100644 (file)
@@ -1,3 +1,12 @@
+2003-10-11  Roger Sayle  <roger@eyesopen.com>
+
+       * expr.c (expand_expr <PLUS_EXPR>): Let expand_operands call
+       safe_from_p for us, once it chooses an evaluation order.
+       (expand_expr <MULT_EXPR>): Likewise.
+       (expand_expr <MIN_EXPR> <MAX_EXPR>): Likewise.  If expand_operands
+       places the second operand in "target", swap the operands.
+       (do_store_flag): Let expand_operands call safe_from_p for us.
+
 2003-10-11  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR optimization/12544
index a973065..532a227 100644 (file)
@@ -7775,9 +7775,6 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
            }
        }
 
-      if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1), 1))
-       subtarget = 0;
-
       /* No sense saving up arithmetic to be done
         if it's all in the wrong mode to form part of an address.
         And force_operand won't know whether to sign-extend or
@@ -7885,9 +7882,6 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
                                             TYPE_MODE (TREE_TYPE (exp1))));
        }
 
-      if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1), 1))
-       subtarget = 0;
-
       if (modifier == EXPAND_STACK_PARM)
        target = 0;
 
@@ -8066,7 +8060,6 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
       target = original_target;
       if (target == 0
          || modifier == EXPAND_STACK_PARM
-         || ! safe_from_p (target, TREE_OPERAND (exp, 1), 1)
          || (GET_CODE (target) == MEM && MEM_VOLATILE_P (target))
          || GET_MODE (target) != mode
          || (GET_CODE (target) == REG
@@ -8093,6 +8086,14 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
       if (GET_CODE (target) == MEM)
        target = gen_reg_rtx (mode);
 
+      /* If op1 was placed in target, swap op0 and op1.  */
+      if (target != op0 && target == op1)
+       {
+         rtx tem = op0;
+         op0 = op1;
+         op1 = tem;
+       }
+
       if (target != op0)
        emit_move_insn (target, op0);
 
@@ -9589,8 +9590,7 @@ do_store_flag (tree exp, rtx target, enum machine_mode mode, int only_cheap)
     }
 
   if (! get_subtarget (target)
-      || GET_MODE (subtarget) != operand_mode
-      || ! safe_from_p (subtarget, arg1, 1))
+      || GET_MODE (subtarget) != operand_mode)
     subtarget = 0;
 
   expand_operands (arg0, arg1, subtarget, &op0, &op1, 0);
index 9c10508..331794d 100644 (file)
@@ -1,3 +1,7 @@
+2003-10-11  Roger Sayle  <roger@eyesopen.com>
+
+       * gcc.c-torture/execute/20031011-1.c: New testcase.
+
 2003-10-11  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.c-torture/compile/20031011-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20031011-1.c b/gcc/testsuite/gcc.c-torture/execute/20031011-1.c
new file mode 100644 (file)
index 0000000..9aa40b8
--- /dev/null
@@ -0,0 +1,31 @@
+/* Check that MAX_EXPR and MIN_EXPR are working properly.  */
+
+#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
+#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
+
+extern void abort (void);
+
+int main()
+{
+  int ll_bitsize, ll_bitpos;
+  int rl_bitsize, rl_bitpos;
+  int end_bit;
+
+  ll_bitpos = 32;  ll_bitsize = 32;
+  rl_bitpos = 0;   rl_bitsize = 32;
+
+  end_bit = MAX (ll_bitpos + ll_bitsize, rl_bitpos + rl_bitsize);
+  if (end_bit != 64)
+    abort ();
+  end_bit = MAX (rl_bitpos + rl_bitsize, ll_bitpos + ll_bitsize);
+  if (end_bit != 64)
+    abort ();
+  end_bit = MIN (ll_bitpos + ll_bitsize, rl_bitpos + rl_bitsize);
+  if (end_bit != 32)
+    abort ();
+  end_bit = MIN (rl_bitpos + rl_bitsize, ll_bitpos + ll_bitsize);
+  if (end_bit != 32)
+    abort ();
+  return 0;
+}
+