From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C2D2A385828C; Fri, 12 Jan 2024 10:24:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2D2A385828C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705055058; bh=2IGFrH9wqH2E3RQsg5cFqCCW3+nPuvnkdFf9ybzVAQA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lkVf+i2xXpq7F5Fh4Gg9rMiIA5CEGsbMG97nNP+SaL3QENx9yVMi9Hc3cUEzt1LRl eZUjt9VKn91XbUM3ZuoCkPi7M553ghKWF71dekTruirGkNJdERl0hEPvj6s59cRiif chfsZRHj5lc1+LODJz1M+7Miy3ctv6zgPZOsGF2Y= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113334] wrong code with _BitInt() shift at -O0 Date: Fri, 12 Jan 2024 10:24:17 +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: wrong-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=3D113334 --- Comment #2 from GCC Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:c75579169eba269a7c339d80b5ac0239f36a58b3 commit r14-7182-gc75579169eba269a7c339d80b5ac0239f36a58b3 Author: Jakub Jelinek Date: Fri Jan 12 11:23:27 2024 +0100 lower-bitint: Fix up handling of unsigned INTEGER_CSTs operands with lo= ts of 1s in the upper bits [PR113334] For INTEGER_CST operands, the code decides if it should emit the whole INTEGER_CST into memory, or if there are enough upper bits either all 0s or all 1s to warrant an optimization, where we use memory for lower lim= bs or even just an INTEGER_CST for least significant limb and fill in the rest of limbs with 0s or 1s. Unfortunately when not using bitint_min_cst_precision, the code was using tree_int_cst_sgn (op) < 0 to determine whether to fill in the upper bits with 1s or 0s. That is incorrect for TYPE_UNSIGNED INTEGER_CSTs which have higher limbs full of ones, we really want to check here whether the most significant bit is set or clear. Fixed thusly. 2024-01-12 Jakub Jelinek PR tree-optimization/113334 * gimple-lower-bitint.cc (bitint_large_huge::handle_operand): U= se wi::neg_p (wi::to_wide (op)) instead of tree_int_cst_sgn (op) <= 0 to determine if number should be extended by all ones rather th= an zero extended. * gcc.dg/torture/bitint-46.c: New test.=