* cse.c (cse_insn): Simplify REG_EQUAL note on libcalls when
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 May 2003 17:49:44 +0000 (17:49 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 30 May 2003 17:49:44 +0000 (17:49 +0000)
making a substitution.
(dead_libcall_p): If directly replacing a libcall with a
constant value produces an invalid instruction, also try forcing
the constant into the constant pool.
* expr.c (emit_move_insn): Add a REG_EQUAL note when it is not
obvious that the source is a constant.
(compress_float_constant): Use set_unique_reg_note to place
REG_EQUAL notes on instructions.

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

gcc/ChangeLog
gcc/cse.c
gcc/expr.c

index 79063f7..ff28c20 100644 (file)
@@ -1,3 +1,15 @@
+2003-05-30  Roger Sayle  <roger@eyesopen.com>
+
+       * cse.c (cse_insn): Simplify REG_EQUAL note on libcalls when
+       making a substitution.
+       (dead_libcall_p): If directly replacing a libcall with a
+       constant value produces an invalid instruction, also try forcing
+       the constant into the constant pool.
+       * expr.c (emit_move_insn): Add a REG_EQUAL note when it is not
+       obvious that the source is a constant.
+       (compress_float_constant): Use set_unique_reg_note to place
+       REG_EQUAL notes on instructions.
+
 2003-05-30  Eric Christopher  <echristo@redhat.com>
 
        * config/mips/mips.c (extern_list): Add GTY marker.
index 671fd06..4f59bab 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -5550,8 +5550,8 @@ cse_insn (insn, libcall_insn)
                  && (GET_CODE (sets[i].orig_src) == REG
                      || GET_CODE (sets[i].orig_src) == SUBREG
                      || GET_CODE (sets[i].orig_src) == MEM))
-               replace_rtx (REG_NOTES (libcall_insn), sets[i].orig_src,
-                            copy_rtx (new));
+               simplify_replace_rtx (REG_NOTES (libcall_insn),
+                                     sets[i].orig_src, copy_rtx (new));
 
              /* The result of apply_change_group can be ignored; see
                 canon_reg.  */
@@ -7632,33 +7632,49 @@ dead_libcall_p (insn, counts)
      rtx insn;
      int *counts;
 {
-  rtx note;
+  rtx note, set, new;
+
   /* See if there's a REG_EQUAL note on this insn and try to
      replace the source with the REG_EQUAL expression.
 
      We assume that insns with REG_RETVALs can only be reg->reg
      copies at this point.  */
   note = find_reg_note (insn, REG_EQUAL, NULL_RTX);
-  if (note)
-    {
-      rtx set = single_set (insn);
-      rtx new = simplify_rtx (XEXP (note, 0));
+  if (!note)
+    return false;
+
+  set = single_set (insn);
+  if (!set)
+    return false;
 
-      if (!new)
-       new = XEXP (note, 0);
+  new = simplify_rtx (XEXP (note, 0));
+  if (!new)
+    new = XEXP (note, 0);
 
-      /* While changing insn, we must update the counts accordingly.  */
-      count_reg_usage (insn, counts, NULL_RTX, -1);
+  /* While changing insn, we must update the counts accordingly.  */
+  count_reg_usage (insn, counts, NULL_RTX, -1);
 
-      if (set && validate_change (insn, &SET_SRC (set), new, 0))
+  if (validate_change (insn, &SET_SRC (set), new, 0))
+    {
+      count_reg_usage (insn, counts, NULL_RTX, 1);
+      remove_note (insn, find_reg_note (insn, REG_RETVAL, NULL_RTX));
+      remove_note (insn, note);
+      return true;
+    }
+
+  if (CONSTANT_P (new))
+    {
+      new = force_const_mem (GET_MODE (SET_DEST (set)), new);
+      if (new && validate_change (insn, &SET_SRC (set), new, 0))
        {
-          count_reg_usage (insn, counts, NULL_RTX, 1);
+         count_reg_usage (insn, counts, NULL_RTX, 1);
          remove_note (insn, find_reg_note (insn, REG_RETVAL, NULL_RTX));
          remove_note (insn, note);
          return true;
        }
-       count_reg_usage (insn, counts, NULL_RTX, 1);
     }
+      
+  count_reg_usage (insn, counts, NULL_RTX, 1);
   return false;
 }
 
index 770bef4..e3872e8 100644 (file)
@@ -3166,7 +3166,7 @@ emit_move_insn (x, y)
 {
   enum machine_mode mode = GET_MODE (x);
   rtx y_cst = NULL_RTX;
-  rtx last_insn;
+  rtx last_insn, set;
 
   x = protect_from_queue (x, 1);
   y = protect_from_queue (y, 0);
@@ -3184,9 +3184,10 @@ emit_move_insn (x, y)
          && (last_insn = compress_float_constant (x, y)))
        return last_insn;
 
+      y_cst = y;
+
       if (!LEGITIMATE_CONSTANT_P (y))
        {
-         y_cst = y;
          y = force_const_mem (mode, y);
 
          /* If the target's cannot_force_const_mem prevented the spill,
@@ -3217,7 +3218,10 @@ emit_move_insn (x, y)
 
   last_insn = emit_move_insn_1 (x, y);
 
-  if (y_cst && GET_CODE (x) == REG)
+  if (y_cst && GET_CODE (x) == REG
+      && (set = single_set (last_insn)) != NULL_RTX
+      && SET_DEST (set) == x
+      && ! rtx_equal_p (y_cst, SET_SRC (set)))
     set_unique_reg_note (last_insn, REG_EQUAL, y_cst);
 
   return last_insn;
@@ -3621,8 +3625,7 @@ compress_float_constant (x, y)
       last_insn = get_last_insn ();
 
       if (GET_CODE (x) == REG)
-       REG_NOTES (last_insn)
-         = gen_rtx_EXPR_LIST (REG_EQUAL, y, REG_NOTES (last_insn));
+       set_unique_reg_note (last_insn, REG_EQUAL, y);
 
       return last_insn;
     }