From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2B6EA3858407; Fri, 9 Feb 2024 10:09:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B6EA3858407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707473361; bh=wCeeiw2OiADsY+A7ps/RQUME5IzmNFmn/hl+bW04Wy8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=twg5nL56NrkMmkCAONBPb2VDErhV3pvLMGZNmy1sz7m+awr+lNidcA1hJGhKWJdeh LLUQLVFGxFeTEENu+H4q+CyGM+SYrLZQo/TZhyYsohve1awcxed1lqVMpEvuf9tFVO pLPa+oaHjI/fu+mlVVGQT3rJDsOcFFRooNr84pEs= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/113415] ICE: RTL check: -mstringop-strategy=byte_loop vs inline-asm goto with block copies Date: Fri, 09 Feb 2024 10:09:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-checking, ice-on-invalid-code, inline-asm X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113415 --- Comment #7 from GCC Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:0ad1884089c0fad4dfc72516bc68ec508cba1832 commit r14-8896-g0ad1884089c0fad4dfc72516bc68ec508cba1832 Author: Jakub Jelinek Date: Fri Feb 9 11:08:33 2024 +0100 expand: Fix asm goto expansion [PR113415] The asm goto expansion ICEs on the following testcase (which normally is rejected later), because expand_asm_stmt emits the code to copy the large var out of the out operand to its memory location into after_rtl_seq ... after_rtl_end sequence and because it is asm goto, it duplicates the sequence on each successor edge of the asm goto. The problem is that with -mstringop-strategy=3Dbyte_loop that sequence contains loops, so CODE_LABELs, JUMP_INSNs, with other strategies could contain CALL_INSNs etc. But the copying is done using a loop doing emit_insn (copy_insn (PATTERN (curr))); which does the right thing solely for INSNs, it will do the wrong thing for JUMP_INSNs, CALL_INSNs, CODE_LABELs (with RTL checking even ICE on them), BARRIERs and the like. The following patch partially fixes it (with the hope that such stuff o= nly occurs in asms that really can't be accepted; if one uses say "=3Drm" or "=3Dg" constraint then the operand uses the memory directly and nothing= is copied) by using the duplicate_insn_chain function which is used e.g. in RTL loop unrolling = and which can handle JUMP_INSNs, CALL_INSNs, BARRIERs etc. As it is meant to operate on sequences inside of basic blocks, it doesn= 't handle CODE_LABELs (well, it skips them), so if we need a solution that will be correct at runtime here for those cases, we'd need to do further work (e.g. still use duplicate_insn_chain, but if we notice any CODE_LABELs, walk the sequence again, add copies of the CODE_LABELs and then remap references to the old CODE_LABELs in the copied sequence to the new one= s). Because as is now, if the code in one of the sequence copies (where the CODE_LABELs have been left out) decides to jump to such a CODE_LABEL, it will jump to the CODE_LABEL which has been in the original sequence (wh= ich the code emits on the last edge, after all, duplicating the sequence EDGE_COUNT times and throwing away the original was wasteful, compared = to doing that just EDGE_COUNT - 1 times and using the original. 2024-02-09 Jakub Jelinek PR middle-end/113415 * cfgexpand.cc (expand_asm_stmt): For asm goto, use duplicate_insn_chain to duplicate after_rtl_seq sequence instead of hand written loop with emit_insn of copy_insn and emit origi= nal after_rtl_seq on the last edge. * gcc.target/i386/pr113415.c: New test.=