From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0B1F7385829C; Fri, 15 Mar 2024 05:19:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B1F7385829C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710479948; bh=wt86do3OzY8fGUjW1MRKvx3FMgegX/AcLH/md1a8zWM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oLyZe+Nq+QhBCJn9hJM6LDR4XJhDajvGF2p6+EeQ507epC1bFZFzEsSsN+rsozcmo DuGaeRyAFdL2ZizmkdwmtrrRCrQSmHlv2Mb/ypl3W7C7uGOid4YyHF4Byhx/oib9X/ PfKpG0XMHA3KqAHbkVjUzAFOdOJ/v75NSrDj4cHA= From: "eggert at cs dot ucla.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/114347] wrong constant folding when casting __bf16 to int Date: Fri, 15 Mar 2024 05:19:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eggert at cs dot ucla.edu 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: 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=3D114347 --- Comment #2 from Paul Eggert --- (In reply to Andrew Pinski from comment #1) > I am not so sure that 257.0bf16 gets rounded to 256. It should get rounded to 256, since 257 has no exact representation in __bf= 16 and 256 is the closest representable value. And GCC does this correctly in my experiments. If I compile this: __bf16 w =3D 256.0bf16; __bf16 x =3D 257.0bf16; with "gcc -O2 -S", the assembly code says ".value 17280" for both constants= .=