From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AB2D538930E3; Thu, 20 Jun 2024 13:24:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB2D538930E3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1718889844; bh=x4s31RRXLOvRdU1tHnOQ92p1QV9b5wugZ8Ni1w4N2js=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oo1TFcsYA722lSIvfgXWRGHR2E5ytrS20a1Lzmyiq7vy+fkpcD8WbGVxzSV0PdHxL Mq+Gecgr9rPpQ/juGKWXWqDrIQmMpFTs8K9g0vLtXDC8mAHwLSWX3ODYr+Pc4AXzd7 ePZDTBsbTP/AR2tKdH9pdwkLCpvUELLccaZIk+88= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115337] wrong code with _BitInt() __builtin_stdc_first_leading_one/__builtin_clzg (with -1 as second arg) at -O2 Date: Thu, 20 Jun 2024 13:24:03 +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: 15.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED 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=3D115337 --- Comment #16 from GCC Commits --- The releases/gcc-11 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:b724525c9779bbf93c4905dc3d54296f5e39e607 commit r11-11514-gb724525c9779bbf93c4905dc3d54296f5e39e607 Author: Jakub Jelinek Date: Tue Jun 4 15:49:41 2024 +0200 fold-const: Fix up CLZ handling in tree_call_nonnegative_warnv_p [PR115= 337] The function currently incorrectly assumes all the __builtin_clz* and .= CLZ calls have non-negative result. That is the case of the former which i= s UB on zero and has [0, prec-1] return value otherwise, and is the case of = the single argument .CLZ as well (again, UB on zero), but for two argument .CLZ is the case only if the second argument is also nonnegative (or if= we know the argument can't be zero, but let's do that just in the ranger IMHO). The following patch does that. 2024-06-04 Jakub Jelinek PR tree-optimization/115337 * fold-const.c (tree_call_nonnegative_warnv_p) : If fn is CFN_CLZ, use CLZ_DEFINED_VALUE_AT. (cherry picked from commit b82a816000791e7a286c7836b3a473ec0e2a577b)=