From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3BDCE3858416; Fri, 12 Jan 2024 16:12:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3BDCE3858416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705075962; bh=prem2N+3v8N/w6JW+VtSw+unkk85yjiQDV6X7l7+Q2o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=y69G7MY0F+qxOYWUqf7dmdwk2Bi5sCqbM/gpN02vpPXOx9yHVT6QhXJnwZ6qRNXIC xncuZ+IBeXnecaIl/Vu9E6BfYN0Hn9Pn69DYA4NUgVbABiQ7a7CO8uYS0m3DzTjiqc rqdmt/sYXAQ0/2T3CISvlIOuwgJgm++iwGW5IIeE= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/113315] during GIMPLE pass: bitintlower0 ICE: in lower_mergeable_stmt, at gimple-lower-bitint.cc:2310 with _BitInt() used as array index Date: Fri, 12 Jan 2024 16:12:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c 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: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub 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=3D113315 --- Comment #4 from GCC Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:95440171d0e615b0a1aa6863e41ba30df86ac3f4 commit r14-7200-g95440171d0e615b0a1aa6863e41ba30df86ac3f4 Author: Jakub Jelinek Date: Fri Jan 12 17:11:49 2024 +0100 c: Avoid _BitInt indexes > sizetype in ARRAY_REFs [PR113315] When build_array_ref doesn't use ARRAY_REF, it casts the index to sizet= ype already, performs POINTER_PLUS_EXPR and then dereferences. While when emitting ARRAY_REF, we try to keep index expression as is in whatever type it had, which is reasonable e.g. for signed or unsigned t= ypes narrower than sizetype for loop optimizations etc. But if the index is wider than sizetype, we are unnecessarily computing bits beyond what is needed. For {,unsigned }__int128 on 64-bit arches or {,unsigned }long long on 32-bit arches we've been doing that for decades, so the following patch doesn't propose to change that (might be stage1 material), but for _BitInt at least the _BitInt lowering code doesn't expect to see large/huge _BitInt in the ARRAY_REF indexes, I was expecting one would see just casts of those to sizetype. So, the following patch makes sure that large/huge _BitInt indexes don't appear in ARRAY_REFs. 2024-01-12 Jakub Jelinek PR c/113315 * c-typeck.cc (build_array_ref): If index has BITINT_TYPE type = with precision larger than sizetype precision, convert it to sizetyp= e. * gcc.dg/bitint-65.c: New test. * gcc.dg/bitint-66.c: New test.=