Mercurial > hg > CbC > CbC_gcc
diff gcc/regcprop.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
line wrap: on
line diff
--- a/gcc/regcprop.c Fri Oct 27 22:46:09 2017 +0900 +++ b/gcc/regcprop.c Thu Oct 25 07:37:49 2018 +0900 @@ -1,5 +1,5 @@ /* Copy propagation on hard registers for the GNU compiler. - Copyright (C) 2000-2017 Free Software Foundation, Inc. + Copyright (C) 2000-2018 Free Software Foundation, Inc. This file is part of GCC. @@ -237,7 +237,11 @@ kill_clobbered_value (rtx x, const_rtx set, void *data) { struct value_data *const vd = (struct value_data *) data; - if (GET_CODE (set) == CLOBBER) + gcc_assert (GET_CODE (set) != CLOBBER_HIGH || REG_P (x)); + + if (GET_CODE (set) == CLOBBER + || (GET_CODE (set) == CLOBBER_HIGH + && reg_is_clobbered_by_clobber_high (x, XEXP (set, 0)))) kill_value (x, vd); } @@ -257,7 +261,9 @@ struct kill_set_value_data *ksvd = (struct kill_set_value_data *) data; if (rtx_equal_p (x, ksvd->ignore_set_reg)) return; - if (GET_CODE (set) != CLOBBER) + + gcc_assert (GET_CODE (set) != CLOBBER_HIGH || REG_P (x)); + if (GET_CODE (set) != CLOBBER && GET_CODE (set) != CLOBBER_HIGH) { kill_value (x, ksvd->vd); if (REG_P (x)) @@ -345,7 +351,8 @@ We can't properly represent the latter case in our tables, so don't record anything then. */ else if (sn < hard_regno_nregs (sr, vd->e[sr].mode) - && subreg_lowpart_offset (GET_MODE (dest), vd->e[sr].mode) != 0) + && maybe_ne (subreg_lowpart_offset (GET_MODE (dest), + vd->e[sr].mode), 0U)) return; /* If SRC had been assigned a mode narrower than the copy, we can't @@ -405,9 +412,12 @@ { int copy_nregs = hard_regno_nregs (copy_regno, copy_mode); int use_nregs = hard_regno_nregs (copy_regno, new_mode); - int copy_offset - = GET_MODE_SIZE (copy_mode) / copy_nregs * (copy_nregs - use_nregs); - unsigned int offset + poly_uint64 bytes_per_reg; + if (!can_div_trunc_p (GET_MODE_SIZE (copy_mode), + copy_nregs, &bytes_per_reg)) + return NULL_RTX; + poly_uint64 copy_offset = bytes_per_reg * (copy_nregs - use_nregs); + poly_uint64 offset = subreg_size_lowpart_offset (GET_MODE_SIZE (new_mode) + copy_offset, GET_MODE_SIZE (orig_mode)); regno += subreg_regno_offset (regno, orig_mode, offset, new_mode); @@ -428,6 +438,8 @@ machine_mode mode = GET_MODE (reg); unsigned int i; + gcc_assert (regno < FIRST_PSEUDO_REGISTER); + /* If we are accessing REG in some mode other that what we set it in, make sure that the replacement is valid. In particular, consider (set (reg:DI r11) (...)) @@ -745,14 +757,13 @@ bool is_asm, any_replacements; rtx set; rtx link; - bool replaced[MAX_RECOG_OPERANDS]; bool changed = false; struct kill_set_value_data ksvd; next = NEXT_INSN (insn); if (!NONDEBUG_INSN_P (insn)) { - if (DEBUG_INSN_P (insn)) + if (DEBUG_BIND_INSN_P (insn)) { rtx loc = INSN_VAR_LOCATION_LOC (insn); if (!VAR_LOC_UNKNOWN_P (loc)) @@ -843,6 +854,12 @@ && reg_overlap_mentioned_p (XEXP (link, 0), SET_SRC (set))) set = NULL; } + + /* We need to keep CFI info correct, and the same on all paths, + so we cannot normally replace the registers REG_CFA_REGISTER + refers to. Bail. */ + if (REG_NOTE_KIND (link) == REG_CFA_REGISTER) + goto did_replacement; } /* Special-case plain move instructions, since we may well @@ -866,7 +883,8 @@ /* And likewise, if we are narrowing on big endian the transformation is also invalid. */ if (REG_NREGS (src) < hard_regno_nregs (regno, vd->e[regno].mode) - && subreg_lowpart_offset (mode, vd->e[regno].mode) != 0) + && maybe_ne (subreg_lowpart_offset (mode, + vd->e[regno].mode), 0U)) goto no_move_special_case; } @@ -927,7 +945,7 @@ eldest live copy that's in an appropriate register class. */ for (i = 0; i < n_ops; i++) { - replaced[i] = false; + bool replaced = false; /* Don't scan match_operand here, since we've no reg class information to pass down. Any operands that we could @@ -944,26 +962,26 @@ if (recog_data.operand_type[i] == OP_IN) { if (op_alt[i].is_address) - replaced[i] + replaced = replace_oldest_value_addr (recog_data.operand_loc[i], alternative_class (op_alt, i), VOIDmode, ADDR_SPACE_GENERIC, insn, vd); else if (REG_P (recog_data.operand[i])) - replaced[i] + replaced = replace_oldest_value_reg (recog_data.operand_loc[i], alternative_class (op_alt, i), insn, vd); else if (MEM_P (recog_data.operand[i])) - replaced[i] = replace_oldest_value_mem (recog_data.operand[i], - insn, vd); + replaced = replace_oldest_value_mem (recog_data.operand[i], + insn, vd); } else if (MEM_P (recog_data.operand[i])) - replaced[i] = replace_oldest_value_mem (recog_data.operand[i], - insn, vd); + replaced = replace_oldest_value_mem (recog_data.operand[i], + insn, vd); /* If we performed any replacement, update match_dups. */ - if (replaced[i]) + if (replaced) { int j; rtx new_rtx; @@ -982,13 +1000,6 @@ { if (! apply_change_group ()) { - for (i = 0; i < n_ops; i++) - if (replaced[i]) - { - rtx old = *recog_data.operand_loc[i]; - recog_data.operand[i] = old; - } - if (dump_file) fprintf (dump_file, "insn %u: reg replacements not verified\n", @@ -1296,7 +1307,7 @@ copyprop_hardreg_forward_1 (bb, all_vd + bb->index); } - if (MAY_HAVE_DEBUG_INSNS) + if (MAY_HAVE_DEBUG_BIND_INSNS) { FOR_EACH_BB_FN (bb, fun) if (bitmap_bit_p (visited, bb->index)