From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CCF1C3860005; Fri, 15 Mar 2024 09:03:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CCF1C3860005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710493397; bh=ncsii1kRqv1y23dkngiKjM19GxK39CE0it5lPEDm0+s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=yNsDChc2BnOwF/6ufwfDAvbe9TNaqnC7GBlttZ9PgZkIqICH5+Sn6DMyHnqEj6QUG 3PsJu5mp8dUkGZZfrUF/4oycdAsu8ggDcmpt8eBfbU9Y2PXVyBnTrCoSd59ewoVWlq DKHo0rQYZq2tWl67LMtKDwGU5ZFG9+DY780r4sQU= From: "rguenth 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: Fri, 15 Mar 2024 09:03:16 +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: rguenth 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: keywords 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=3D114347 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code CC| |jsm28 at gcc dot gnu.org --- Comment #3 from Richard Biener --- I suspect we fail to round at parsing time. I see we get to see unit-size align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff6a33888 precision:16> arg:0 unit-size align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-ty= pe 0x7ffff6a332a0 precision:32 pointer_to_this > constant 2.57e+2> and then upon processing the (int) cast simply strip the excess_precision_e= xpr. #0 convert (type=3D,=20 expr=3D) at /home/rguenther/src/trunk/gcc/c/c-convert.cc:253 #1 0x0000000000d8e9e2 in build_c_cast (loc=3D263296,=20 type=3D, expr=3D) at /home/rguenther/src/trunk/gcc/c/c-typeck.cc:6387 #2 0x0000000000d8f01c in c_cast_expr (loc=3D263296, type_name=3D0x46c6760,= =20 expr=3D) at /home/rguenther/src/trunk/gcc/c/c-typeck.cc:6461 /* Build an expression representing a cast to type TYPE of expression EXPR. LOC is the location of the cast-- typically the open paren of the cast. = */ tree build_c_cast (location_t loc, tree type, tree expr) { tree value; bool int_operands =3D EXPR_INT_CONST_OPERANDS (expr); if (TREE_CODE (expr) =3D=3D EXCESS_PRECISION_EXPR) expr =3D TREE_OPERAND (expr, 0); But maybe that's correct behavior here? Or we shouldn't have an excess_precision_expr in the first place for BF16?=