From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 39AE43858D35; Wed, 15 Dec 2021 20:43:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39AE43858D35 From: "vmakarov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/103722] [12 Regression] ICE in extract_constrain_insn building glibc for SH4 Date: Wed, 15 Dec 2021 20:43:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: vmakarov at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Dec 2021 20:43:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103722 --- Comment #1 from Vladimir Makarov --- (In reply to Joseph S. Myers from comment #0) > Created attachment 52003 [details] > preprocessed source >=20 > Build the attached code (from glibc) with -O2 for sh4-linux-gnu. This > produces an ICE: >=20 > malloc-debug.c: In function '__debug_realloc': > malloc-debug.c:267:1: error: insn does not satisfy its constraints: > (insn 955 1863 2 2 (set (reg:SI 76 fr12 [314]) > (reg:SI 146 pr)) 189 {movsi_ie} > (nil)) > during RTL pass: postreload > malloc-debug.c:267:1: internal compiler error: in extract_constrain_insn,= at > recog.c:2670 > 0x5eec04 _fatal_insn(char const*, rtx_def const*, char const*, int, char > const*) > /scratch/jmyers/glibc/many12/src/gcc/gcc/rtl-error.c:108 > 0x5eec2a _fatal_insn_not_found(rtx_def const*, char const*, int, char con= st*) > /scratch/jmyers/glibc/many12/src/gcc/gcc/rtl-error.c:119 > 0xcab367 extract_constrain_insn(rtx_insn*) > /scratch/jmyers/glibc/many12/src/gcc/gcc/recog.c:2670 > 0xc71acd reload_cse_simplify_operands > /scratch/jmyers/glibc/many12/src/gcc/gcc/postreload.c:407 > 0xc732bc reload_cse_simplify > /scratch/jmyers/glibc/many12/src/gcc/gcc/postreload.c:190 > 0xc732bc reload_cse_regs_1 > /scratch/jmyers/glibc/many12/src/gcc/gcc/postreload.c:238 > 0xc7584b reload_cse_regs > /scratch/jmyers/glibc/many12/src/gcc/gcc/postreload.c:66 > 0xc7584b execute > /scratch/jmyers/glibc/many12/src/gcc/gcc/postreload.c:2355 > Please submit a full bug report, > with preprocessed source if appropriate. > Please include the complete backtrace with any bug report. > See for instructions. >=20 > This was introduced (exposed?) by: >=20 > commit a7acb6dca941db2b1c135107dac3a34a20650d5c > Author: Vladimir N. Makarov > Date: Mon Dec 13 13:48:12 2021 -0500 >=20 > [PR99531] Modify pseudo class cost calculation when processing move > involving the pseudo and a hard register I am conforming that it was triggered by my patch. But it is not an IRA bug. The old pass reload (used by SH port) fails to change insn although insn constraints are not satisfied. The insn in quest= ion is move fpreg =3D poreg The old reload is mistaken by cost of moving prreg to fpreg. SH machine co= de provides cost 2 for this. In this case the old reload pass skips checking constraints of the move. The following patch solves the problem: diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 0628f059ca2..e7c8e5f84b7 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -10762,6 +10762,12 @@ sh_register_move_cost (machine_mode mode, && ! REGCLASS_HAS_GENERAL_REG (dstclass)) return 2 * ((GET_MODE_SIZE (mode) + 7) / 8U); + if (((dstclass =3D=3D FP_REGS || dstclass =3D=3D DF_REGS) + && (srcclass =3D=3D PR_REGS)) + || ((srcclass =3D=3D FP_REGS || srcclass =3D=3D DF_REGS) + && (dstclass =3D=3D PR_REGS))) + return 7; + return 2 * ((GET_MODE_SIZE (mode) + 3) / 4U); } The patch also makes IRA to allocate a general reg instead of fpreg which is more costly after applying the patch.=