From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5C5BC3858415; Tue, 9 Apr 2024 18:44:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C5BC3858415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712688256; bh=AR8HXWEMlKVDP5d4flJ2qrE8GpflA+x884EecaoJ4WM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ex+kxM6XA9nxcvO1EXdv7nM3Fe5995ROsZ2Km1ypvP6p9cs8n7Qk7HGnUanOyoMiP 96yd3OG/fpyP2enQSdb2GF+ErUvyRnv2jGFKt7/25T6bNa8xBfSpGspIAYDAautNSq RPlJuv7LXqT1VYEsspUG+fGKCpQDyfrDDMZRFJPc= From: "bruno at clisp dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114659] gcc miscompiles a __builtin_memcpy on i386, leading to wrong results for SNaN Date: Tue, 09 Apr 2024 18:44:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: bruno at clisp dot 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=3D114659 --- Comment #8 from Bruno Haible --- (In reply to Andrew Pinski from comment #6) > I doubt there is not much to be done here. I see it as an incorrect modelization of the x87 hardware, together with a missing distinction in the common expression elimination / aliasing analysi= s. In detail: * Incorrect modelization of the x87 hardware: The compiler seems to assume = that flds MEM_LOCATION_1 fsts MEM_LOCATION_2 will result in MEM_LOCATION_2 having the same value as MEM_LOCATION_1. Th= is is wrong; this is not how the x87 hardware behaves. The actual result is: *MEM_LOCATION_2 =3D convert_snan_to_qnan(*MEM_LOCATION_1). * In the common expression elimination / aliasing analysis, the compilers s= eems to keep track of a set of memory locations MEM_LOCATION_1, ..., MEM_LOCATION_n wh= ich have the same value. In fact, this set needs to be partitioned into two sets: a su= bset which contains the same value, and the complementary subset which contains convert_snan_to_qnan(value). In other words, each element of the set needs to be annotated with a bit = that tells whether the value has been subject to the convert_snan_to_qnan.=