From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1B2AF38708F9; Mon, 13 May 2024 15:09:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B2AF38708F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715612987; bh=iLwZKo4I9qMcNFJYO/kLN4isV0y1xfeBFLp8LeqDDaI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=wkoI7LswshoFiKJnCL9n+adssWbec4ubR4EaiGWy2Sk2V9Te/2+G2/C560i3dWxuR tlCUuJRbrtytezqWsex9hsXqyi5ymn30tanJp34hl8LD4rhC5GwFLuwsv2OxQ0pAWD 31FVhmApcTUz0OIFipvcWfoTu7vh2AnoLQL379Cg= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115073] RISC-V: Gimple fold not honor C[LT]Z_DEFINED_VALUE_AT_ZERO Date: Mon, 13 May 2024 15:09:46 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: cc 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=3D115073 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek --- That is misunderstanding of what C[LT]Z_DEFINED_VALUE_AT_ZERO is. The builtin has always UB on zero. If you want to define it for zero, use x ? __builtin_clz (x) : 32 (and the like) or __builtin_clzg (x, 32) in the source. C[LT]Z_DEFINED_VALUE_AT_ZERO returning 2 then makes sure the compiler can f= old those conditionals or builtins into .CLZ internal calls with 2 arguments wh= ich makes it well defined for all inputs.=