From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 879AE385E020; Wed, 20 Dec 2023 10:34:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 879AE385E020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703068460; bh=ELhfZ0+zKibHBPQOOBddyUkA2LmsuFCePK88dOOukKo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=b4uXPujkl33KCmHRo7wFjaCOs2aGe/OzZmPV6DN04Wsr3cWWX64ETO9yxmRrT2nMI nMt+ysdrKQFDe+tvo5K6c3BjrvFzsv2cABnj1Z7C4T6o8dGlr6Ewf43xdUslmhaAHF joWU7JDpY0W0f8uP9P9q6piS+AOTL44gZcu5Urv4= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112941] during GIMPLE pass: bitintlower ICE: in handle_operand_addr, at gimple-lower-bitint.cc:2126 (gimple-lower-bitint.cc:2134) at -O with _BitInt() Date: Wed, 20 Dec 2023 10:34:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-on-valid-code 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=3D112941 --- Comment #7 from GCC Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:be9e8de628471399ee5abb1e6ba7738139256b67 commit r14-6742-gbe9e8de628471399ee5abb1e6ba7738139256b67 Author: Jakub Jelinek Date: Wed Dec 20 11:32:52 2023 +0100 lower-bitint: Fix up handling of nested casts in mergeable stmt handling [PR112941] The following patch fixes 2 issues in handling of casts for mergeable stmts. The first hunk fixes the case when we have two nested casts (typically after optimization that is zero-extension of a sign-extension because everything else should have been folded into a single cast). If the lowering of the outer cast needs to make the code conditional (e.g. for (...) { if (idx <=3D 32) { if (idx < 32) { ... handle_operand (idx); ... } else { ... handle_operand (32); ... } } ... } ) and the lowering of the inner one as well, right now it creates inval= id SSA form, because even for the inner cast we need a PHI on the loop and the PHI argument from the latch edge is a SSA_NAME initialized in the conditionally executed bb. The hunk fixes that by detecting such a case and adding further PHI nodes at the end of the ifs such that the right value propagates to the next loop iteration. We can use 0 arguments for the other edges because the inner operand handling is only done for the first set of iterations and then the other ifs take over. The rest fixes a case of again invalid SSA form, when for a sign extens= ion we need to use the 0 or -1 value initialized by earlier iteration in a constant idx case, the code was using the value of the loop PHI argum= ent from latch edge rather than result; that is correct for cases expanded in straight line code after the loop, but not inside of the loop for the cases of handle_cast conditionals, there we should use PHI result. This is done in the second hunk and supported by the remaining hunks, where it clears m_bb to tell the code we aren't in the loop anymore. Note, this patch doesn't deal with similar problems during multiplicati= on, division, floating casts etc. where we just emit a library call. I'll need to make sure in that case we don't merge more than one cast per operand. 2023-12-20 Jakub Jelinek PR tree-optimization/112941 * gimple-lower-bitint.cc (bitint_large_huge::handle_cast): If save_cast_conditional, instead of adding assignment of t4 to m_data[save_data_cnt + 1] before m_gsi, add phi nodes such that t4 propagates to m_bb loop. For constant idx, use m_data[save_data_cnt] rather than m_data[save_data_cnt + 1] if inside of the m_bb loop. (bitint_large_huge::lower_mergeable_stmt): Clear m_bb when no longer expanding inside of that loop. (bitint_large_huge::lower_comparison_stmt): Likewise. (bitint_large_huge::lower_addsub_overflow): Likewise. (bitint_large_huge::lower_mul_overflow): Likewise. (bitint_large_huge::lower_bit_query): Likewise. * gcc.dg/bitint-55.c: New test.=