From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1012) id 727083858D33; Fri, 2 Dec 2022 13:24:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 727083858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669987498; bh=W1b6N9kACEK5J4Nc8hkOE6H99Xv8S7E11KrSX8YeZms=; h=From:To:Subject:Date:From; b=PWKMiDBDkNTnpYjhS7P3iSjyPjjxC4tImVIP0IZSXCBtxFwVlGkz3GYvcOwYDr2rM xU8vWZtg/X9qX1TWzF4ONvJQ6ObmLUuBQNokeLU54Pjbea/cMu9+K+oSFzHeyDkUut hg/+f7S952VcY4i2ZBF8uiOjJZZxxSwgxxTiqoWo= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Vladimir Makarov To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4466] LRA: Check hard reg availability of pseudo and its subreg for pseudo reload X-Act-Checkin: gcc X-Git-Author: Vladimir N. Makarov X-Git-Refname: refs/heads/master X-Git-Oldrev: e55251f3d3598ca6e001c4afa51b2ec913b4cac1 X-Git-Newrev: 70596a0fb2a2ec072e1e97e37616e05041dfa4e5 Message-Id: <20221202132458.727083858D33@sourceware.org> Date: Fri, 2 Dec 2022 13:24:58 +0000 (GMT) List-Id: https://gcc.gnu.org/g:70596a0fb2a2ec072e1e97e37616e05041dfa4e5 commit r13-4466-g70596a0fb2a2ec072e1e97e37616e05041dfa4e5 Author: Vladimir N. Makarov Date: Fri Dec 2 08:18:04 2022 -0500 LRA: Check hard reg availability of pseudo and its subreg for pseudo reload Do not reload subreg pseudo if there are hard regs for subreg mode but there are no hard regs for pseudo mode. PR target/106462 gcc/ChangeLog: * lra-constraints.cc (curr_insn_transform): Check available hard regs for pseudo and its subreg to decide what to reload. gcc/testsuite/ChangeLog: * gcc.target/mips/pr106462.c: New test. Diff: --- gcc/lra-constraints.cc | 13 ++++++++++++- gcc/testsuite/gcc.target/mips/pr106462.c | 12 ++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index d92ab76908c..02b5ab4a316 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -4582,7 +4582,18 @@ curr_insn_transform (bool check_only_p) || (partial_subreg_p (mode, GET_MODE (reg)) && known_le (GET_MODE_SIZE (GET_MODE (reg)), UNITS_PER_WORD) - && WORD_REGISTER_OPERATIONS))) + && WORD_REGISTER_OPERATIONS)) + /* Avoid the situation when there are no available hard regs + for the pseudo mode but there are ones for the subreg + mode: */ + && !(goal_alt[i] != NO_REGS + && REGNO (reg) >= FIRST_PSEUDO_REGISTER + && (prohibited_class_reg_set_mode_p + (goal_alt[i], reg_class_contents[goal_alt[i]], + GET_MODE (reg))) + && !(prohibited_class_reg_set_mode_p + (goal_alt[i], reg_class_contents[goal_alt[i]], + mode)))) { /* An OP_INOUT is required when reloading a subreg of a mode wider than a word to ensure that data beyond the diff --git a/gcc/testsuite/gcc.target/mips/pr106462.c b/gcc/testsuite/gcc.target/mips/pr106462.c new file mode 100644 index 00000000000..c9105409524 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/pr106462.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mabi=64 -msingle-float" } */ + +extern void bar (float x, short y); + +void foo (int argc) +{ + short c = argc * 2; + float a = (float)(short)c, b = 9.5; + + bar (b/a, c); +}