From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2140) id CE46B3858C56; Sun, 27 Mar 2022 20:36:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE46B3858C56 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Alexandre Oliva To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/aoliva/heads/testme)] try multi dest registers in default_zero_call_used_regs X-Act-Checkin: gcc X-Git-Author: Alexandre Oliva X-Git-Refname: refs/users/aoliva/heads/testme X-Git-Oldrev: 08e69332881f8d28ce8b559ffba1900ae5c0d5ee X-Git-Newrev: 0369a06a84786fdb63f7ec20f16865870b38371f Message-Id: <20220327203657.CE46B3858C56@sourceware.org> Date: Sun, 27 Mar 2022 20:36:57 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2022 20:36:57 -0000 https://gcc.gnu.org/g:0369a06a84786fdb63f7ec20f16865870b38371f commit 0369a06a84786fdb63f7ec20f16865870b38371f Author: Alexandre Oliva Date: Sun Mar 27 17:35:48 2022 -0300 try multi dest registers in default_zero_call_used_regs When the mode of regno_reg_rtx is not hard_regno_mode_ok for the target, try grouping the register with subsequent ones. This enables s16 to s31 and their hidden pairs to be zeroed with the default logic on some arm variants. for gcc/ChangeLog * targhooks.c (default_zero_call_used_regs): Attempt to group regs that the target refuses to use in their natural modes. Diff: --- gcc/targhooks.cc | 79 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 9 deletions(-) diff --git a/gcc/targhooks.cc b/gcc/targhooks.cc index fc49235eb38..bdaab9c63c7 100644 --- a/gcc/targhooks.cc +++ b/gcc/targhooks.cc @@ -1035,16 +1035,45 @@ default_zero_call_used_regs (HARD_REG_SET need_zeroed_hardregs) if (TEST_HARD_REG_BIT (need_zeroed_hardregs, regno)) { rtx_insn *last_insn = get_last_insn (); - machine_mode mode = GET_MODE (regno_reg_rtx[regno]); + rtx regno_rtx = regno_reg_rtx[regno]; + machine_mode mode = GET_MODE (regno_rtx); + + /* If the natural mode doesn't work, try some wider mode. */ + if (!targetm.hard_regno_mode_ok (regno, mode)) + { + for (int nregs = 2; + regno + nregs <= FIRST_PSEUDO_REGISTER + && TEST_HARD_REG_BIT (need_zeroed_hardregs, + regno + nregs - 1); + nregs++) + { + mode = choose_hard_reg_mode (regno, nregs, 0); + if (mode == E_VOIDmode) + continue; + gcc_checking_assert (targetm.hard_regno_mode_ok (regno, mode)); + regno_rtx = gen_rtx_REG (mode, regno); + break; + } + if (mode != GET_MODE (regno_rtx) + || regno_rtx == regno_reg_rtx[regno]) + { + SET_HARD_REG_BIT (failed, regno); + continue; + } + } + rtx zero = CONST0_RTX (mode); - rtx_insn *insn = emit_move_insn (regno_reg_rtx[regno], zero); + rtx_insn *insn = emit_move_insn (regno_rtx, zero); if (!valid_insn_p (insn)) { SET_HARD_REG_BIT (failed, regno); delete_insns_since (last_insn); } else - progress = true; + { + progress = true; + regno += hard_regno_nregs (regno, mode) - 1; + } } /* Now retry with copies from zeroed registers, as long as we've @@ -1060,7 +1089,34 @@ default_zero_call_used_regs (HARD_REG_SET need_zeroed_hardregs) for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) if (TEST_HARD_REG_BIT (retrying, regno)) { - machine_mode mode = GET_MODE (regno_reg_rtx[regno]); + rtx regno_rtx = regno_reg_rtx[regno]; + machine_mode mode = GET_MODE (regno_rtx); + + /* If the natural mode doesn't work, try some wider mode. */ + if (!targetm.hard_regno_mode_ok (regno, mode)) + { + for (int nregs = 2; + regno + nregs <= FIRST_PSEUDO_REGISTER + && TEST_HARD_REG_BIT (need_zeroed_hardregs, + regno + nregs - 1); + nregs++) + { + mode = choose_hard_reg_mode (regno, nregs, 0); + if (mode == E_VOIDmode) + continue; + gcc_checking_assert (targetm.hard_regno_mode_ok (regno, + mode)); + regno_rtx = gen_rtx_REG (mode, regno); + break; + } + if (mode != GET_MODE (regno_rtx) + || regno_rtx == regno_reg_rtx[regno]) + { + SET_HARD_REG_BIT (failed, regno); + continue; + } + } + bool success = false; /* Look for a source. */ for (unsigned int src = 0; src < FIRST_PSEUDO_REGISTER; src++) @@ -1086,8 +1142,10 @@ default_zero_call_used_regs (HARD_REG_SET need_zeroed_hardregs) /* SRC is usable, try to copy from it. */ rtx_insn *last_insn = get_last_insn (); - rtx zsrc = gen_rtx_REG (mode, src); - rtx_insn *insn = emit_move_insn (regno_reg_rtx[regno], zsrc); + rtx src_rtx = (mode == GET_MODE (regno_reg_rtx[src]) + ? regno_reg_rtx[src] + : gen_rtx_REG (mode, src)); + rtx_insn *insn = emit_move_insn (regno_rtx, src_rtx); if (!valid_insn_p (insn)) /* It didn't work, remove any inserts. We'll look for another SRC. */ @@ -1100,13 +1158,16 @@ default_zero_call_used_regs (HARD_REG_SET need_zeroed_hardregs) } } - /* If nothing worked for REGNO this round, marked it to be + /* If nothing worked for REGNO this round, mark it to be retried if we get another round. */ if (!success) SET_HARD_REG_BIT (failed, regno); else - /* Take note so as to enable another round if needed. */ - progress = true; + { + /* Take note so as to enable another round if needed. */ + progress = true; + regno += hard_regno_nregs (regno, mode) - 1; + } } }