From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 49A443858434; Fri, 23 Feb 2024 10:39:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49A443858434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708684753; bh=16q70FmGRE4wj1foikDzoDKsThBXhxdy9t+nYqkw4KU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RS6xBMr9SPASkcHCgUQoJGLd+/oxwnP0SkM6SyI3BsA+PX3j48vvbfY0hePxWaUwQ hYW4lnSqUC8YTe/IyspbXQJ+rDiWzS3/Z4zt7/pm1STJvQcBMw3Mupy6foOVHAV7v5 U5JHDp8Ouh5MS5s4r6gEJ7gvy8NBdIe1Wd+EEa1I= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/114054] ICE: in reduce_to_bit_field_precision, at expr.cc:12658 with -Og -fwhole-program -fno-tree-ccp -fprofile-use -fno-tree-copy-prop and _BitInt() Date: Fri, 23 Feb 2024 10:39:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-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: 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=3D114054 --- Comment #2 from GCC Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:22121546e0315d25ee419d2389022e3974750885 commit r14-9151-g22121546e0315d25ee419d2389022e3974750885 Author: Jakub Jelinek Date: Fri Feb 23 11:38:18 2024 +0100 expr: Fix REDUCE_BIT_FIELD in multiplication expansion [PR114054] The following testcase ICEs, because the REDUCE_BIT_FIELD macro uses the target variable implicitly: #define REDUCE_BIT_FIELD(expr) (reduce_bit_field=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 \ ? reduce_to_bit_field_precision ((exp= r), \ targ= et, \ type= )=20=20 \ : (expr)) and so when the code below reuses the target variable, documented to be The value may be stored in TARGET if TARGET is nonzero. TARGET is just a suggestion; callers must assume that the rtx returned may not be the same as TARGET. for something unrelated (the value that should be returned), this misbehaves (in the testcase target is set to a CONST_INT, which has VOIDmode and reduce_to_bit_field_precision assert checking doesn't like that). Needed to say that If TARGET is CONST0_RTX, it means that the value will be ignored. but in expand_expr_real_2 does at the start: ignore =3D (target =3D=3D const0_rtx || ((CONVERT_EXPR_CODE_P (code) || code =3D=3D COND_EXPR || code =3D=3D VIEW_CONVERT_E= XPR) && TREE_CODE (type) =3D=3D VOID_TYPE)); /* We should be called only if we need the result. */ gcc_assert (!ignore); - so such target is mainly meant for calls and the like in other routin= es. Certainly doesn't expect that target changes from not being ignored initially to ignore later on and other CONST_INT results as well as anything which is not an object into which anything can be stored. So, the following patch fixes that by using a more appripriate temporary for the result, which other code is using. 2024-02-23 Jakub Jelinek PR rtl-optimization/114054 * expr.cc (expand_expr_real_2) : Use temp variable instead of target parameter for result. * gcc.dg/bitint-92.c: New test.=