OSDN Git Service

* config/m68hc11/m68hc11.c (m68hc11_check_z_replacement): Take
authorciceron <ciceron@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 4 May 2001 21:00:37 +0000 (21:00 +0000)
committerciceron <ciceron@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 4 May 2001 21:00:37 +0000 (21:00 +0000)
into account pre/post increment decrement for 68HC12.
Fix other problems in replacement and fix call to reg_mentioned_p.

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

gcc/ChangeLog
gcc/config/m68hc11/m68hc11.c

index 7d28d81..6950db4 100644 (file)
@@ -1,5 +1,11 @@
 2001-05-04  Stephane Carrez  <Stephane.Carrez@worldnet.fr>
 
+       * config/m68hc11/m68hc11.c (m68hc11_check_z_replacement): Take
+       into account pre/post increment decrement for 68HC12.
+       Fix other problems in replacement and fix call to reg_mentioned_p.
+
+2001-05-04  Stephane Carrez  <Stephane.Carrez@worldnet.fr>
+
        * config/m68hc11/larith.asm (L_regs_frame): New for _.frame.
        Put the soft registers in bss for 68HC12.
        (L_regs_d3_4): New for _.d3 and _.d4.
index f649b9f..8aa5095 100644 (file)
@@ -3851,6 +3851,7 @@ m68hc11_check_z_replacement (insn, info)
   int this_insn_uses_ix;
   int this_insn_uses_iy;
   int this_insn_uses_z;
+  int this_insn_uses_z_in_dst;
   int this_insn_uses_d;
   rtx body;
   int z_dies_here;
@@ -3954,10 +3955,13 @@ m68hc11_check_z_replacement (insn, info)
        {
          if (!reg_mentioned_p (z_reg, src))
            {
-             if (insn == info->first)
+              /* Z reg is used before being set.  Treat this as
+                 a new sequence of Z register replacement.  */
+             if (insn != info->first)
                {
-                 info->must_load_z = 0;
+                  return 0;
                }
+              info->must_load_z = 0;
            }
          info->z_set_count++;
          info->z_value = src;
@@ -3977,9 +3981,23 @@ m68hc11_check_z_replacement (insn, info)
 
       /* If z is used as an address operand (like (MEM (reg z))),
          we can't replace it with d.  */
-      if (this_insn_uses_z && !Z_REG_P (src))
+      if (this_insn_uses_z && !Z_REG_P (src)
+          && !(m68hc11_arith_operator (src, GET_MODE (src))
+               && Z_REG_P (XEXP (src, 0))
+               && !reg_mentioned_p (z_reg, XEXP (src, 1))
+               && insn == info->first
+               && dead_register_here (insn, d_reg)))
        info->can_use_d = 0;
-      this_insn_uses_z |= reg_mentioned_p (z_reg, dst);
+
+      this_insn_uses_z_in_dst = reg_mentioned_p (z_reg, dst);
+      if (TARGET_M6812 && !z_dies_here
+          && ((this_insn_uses_z && side_effects_p (src))
+              || (this_insn_uses_z_in_dst && side_effects_p (dst))))
+        {
+          info->need_save_z = 1;
+          info->z_set_count++;
+        }
+      this_insn_uses_z |= this_insn_uses_z_in_dst;
 
       if (this_insn_uses_z && this_insn_uses_ix && this_insn_uses_iy)
        {
@@ -3996,6 +4014,9 @@ m68hc11_check_z_replacement (insn, info)
          return 0;
        }
 
+      if (this_insn_uses_ix && X_REG_P (dst) && GET_MODE (dst) == SImode)
+        info->can_use_d = 0;
+
       if (info->x_used == 0 && this_insn_uses_ix)
        {
          if (info->y_used)
@@ -4058,7 +4079,7 @@ m68hc11_check_z_replacement (insn, info)
              return 0;
            }
          info->x_used = 1;
-         if (z_dies_here && !reg_mentioned_p (src, ix_reg)
+         if (z_dies_here && !reg_mentioned_p (ix_reg, src)
              && GET_CODE (dst) == REG && REGNO (dst) == HARD_X_REGNUM)
            {
              info->need_save_z = 0;
@@ -4069,6 +4090,13 @@ m68hc11_check_z_replacement (insn, info)
              info->must_restore_reg = 0;
              return 0;
            }
+          if (rtx_equal_p (src, z_reg) && rtx_equal_p (dst, ix_reg))
+            {
+              info->regno = HARD_X_REGNUM;
+              info->must_restore_reg = 0;
+              info->must_save_reg = 0;
+              return 0;
+            }
        }
       if (info->y_used == 0 && this_insn_uses_iy)
        {
@@ -4129,7 +4157,7 @@ m68hc11_check_z_replacement (insn, info)
              return 0;
            }
          info->y_used = 1;
-         if (z_dies_here && !reg_mentioned_p (src, iy_reg)
+         if (z_dies_here && !reg_mentioned_p (iy_reg, src)
              && GET_CODE (dst) == REG && REGNO (dst) == HARD_Y_REGNUM)
            {
              info->need_save_z = 0;
@@ -4140,6 +4168,13 @@ m68hc11_check_z_replacement (insn, info)
              info->must_restore_reg = 0;
              return 0;
            }
+          if (rtx_equal_p (src, z_reg) && rtx_equal_p (dst, iy_reg))
+            {
+              info->regno = HARD_Y_REGNUM;
+              info->must_restore_reg = 0;
+              info->must_save_reg = 0;
+              return 0;
+            }
        }
       if (z_dies_here)
        {
@@ -4193,6 +4228,9 @@ m68hc11_check_z_replacement (insn, info)
              if (Z_REG_P (dst))
                info->z_set_count++;
            }
+          if (TARGET_M6812 && uses_z && side_effects_p (x))
+            info->need_save_z = 1;
+
          if (z_clobber)
            info->need_save_z = 0;
        }