From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 015E13858D1E; Mon, 18 Mar 2024 09:06:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 015E13858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710752786; bh=qh+t0F4OgENy/pgikslPdM5yr+5sHYEV26urKAgVmYo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=R2z7JGFPPDOaRPn+/J+oG7gMHZv8nCcyvnIwSDUiIISSh+CYoebBejJIK0xXJsGmt h6EmGxZlSXGMVxI5stUHnNhImmjt0N5KH/nmDRWEEH8iU/BEnd/bNGnYe2Ff1Mx+oG 4IeIL6msVNHjVDIZ1zMdKz18kzXaNFXBg7l/vFb8= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/114347] wrong constant folding when casting __bf16 to int Date: Mon, 18 Mar 2024 09:06:21 +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: wrong-code 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: 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 #8 from Jakub Jelinek --- (In reply to Richard Biener from comment #7) > (In reply to Jakub Jelinek from comment #6) > > You can use -fexcess-precision=3D16 if you don't want treating _Float16= and > > __bf16 as having excess precision. With excess precision, I think the = above > > behavior is correct. > > You'd need (int) (__bf16) 257.0bf16 to get 256 even with excess precisi= on. >=20 > Ah, -fexcess-precision=3D16 doesn't seem to be documented though I've noticed that too. > (how does > this influence long double handling then?) ix86_get_excess_precision has all the details. x86 has 4 different ways of excess precision, one is not to use excess precision for anything, another = only for __bf16/_Float16 (promote to float), another one is promote everything to long double and last is unpredictable. With -fexcess-precision=3Dfast, with -mavx512fp16 we don't promote anything, without that to float. With -fexcess-precision=3D16 we don't promote anything. With -fexcess-precision=3Dstandard and the implicit case, it depends on -mavx512fp16, -mfpmath=3Dsse, -mfpmath=3D387, -mfpmath=3Dboth etc.=