From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D6AB63861C30; Wed, 11 Mar 2020 08:37:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D6AB63861C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1583915848; bh=eH0GcZwaYM4897/MLLs6mzO/IPrQmE6i7ezVuU53ong=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ryFRHxQKsV+3qs9R3VAW4kgnhWnUoVkLtDmTOGevw368/e3fsu/kPqtKNRaeZO53e 58k2JU2jEGNGtBzh0hcLbLQ8bPkkuZBE/KtKn2TTR5u9ApSeiLwtciNbUUx4xf9BVd FVgzSf3dW9AxDBfNd2HMWpmUGmZUNCnfWTNyhcKw= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/94111] Wrong constant folding: decimal floating-point infinity casted to double -> zero Date: Wed, 11 Mar 2020 08:37:28 +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: 10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2020 08:37:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94111 --- Comment #5 from Jakub Jelinek --- commit r10-7121-g312992f5a07ca25f94d538b08401789c2c764293 Author: Jakub Jelinek Date: Wed Mar 11 09:33:52 2020 +0100 dfp: Fix decimal_to_binary [PR94111] As e.g. decimal_from_decnumber shows, the REAL_VALUE_TYPE representation contains a decimal128 embedded in ->sig only if it is rvc_normal, for other kinds like rvc_inf or rvc_nan, ->sig is ignored and everything is contained in the REAL_VALUE_TYPE flags (cl, sign, signalling and decima= l). decimal_to_binary which is used when folding a decimal{32,64,128} const= ant to a binary floating point type ignores this and thus folds infinities = and NaNs into +0.0. The following patch fixes that by only doing that for rvc_normal. Similarly to the binary to decimal folding, it goes through a string, in order to e.g. deal with canonical NaN mantissas, or binary float formats that don't support infinities and/or NaNs. 2020-03-11 Jakub Jelinek PR middle-end/94111 * dfp.c (decimal_to_binary): Only use decimal128ToString if from->cl is rvc_normal, otherwise use real_to_decimal to print the numbe= r to string. * gcc.dg/dfp/pr94111.c: New test.=