From: Stephane Carrez Date: Fri, 4 May 2001 21:00:37 +0000 (+0200) Subject: m68hc11.c (m68hc11_check_z_replacement): Take into account pre/post increment decreme... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c2f40009aaa80a066044a129ac1e552d96215a1;p=gcc.git m68hc11.c (m68hc11_check_z_replacement): Take into account pre/post increment decrement for 68HC12. * 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. From-SVN: r41848 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7d28d814220..6950db40390 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2001-05-04 Stephane Carrez + + * 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 * config/m68hc11/larith.asm (L_regs_frame): New for _.frame. diff --git a/gcc/config/m68hc11/m68hc11.c b/gcc/config/m68hc11/m68hc11.c index f649b9f1ce7..8aa5095ae4e 100644 --- a/gcc/config/m68hc11/m68hc11.c +++ b/gcc/config/m68hc11/m68hc11.c @@ -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; }