From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 164383857348; Sat, 2 Jul 2022 02:09:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 164383857348 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/106165] incorrect result when using inlined asm implementation of floor() on i686 Date: Sat, 02 Jul 2022 02:09:25 +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: 11.1.0 X-Bugzilla-Keywords: inline-asm, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: DUPLICATE 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: bug_status resolution 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: Sat, 02 Jul 2022 02:09:26 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106165 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |DUPLICATE --- Comment #2 from Andrew Pinski --- -fexcess-precision=3Dstandard (-std=3Dc99 enables -fexcess-precision=3Dstan= dard) or -mfpmath=3Dsse fixes the issue. This is not wrong code but rather the way x87 works for GCC. GCC defaults to using the execess precision of x87 (80bits) and sometimes if the floating point value is kept on the fpu stack, there is no rounding bac= k to 64bits. And that is exactly what you are seeing here really. Anyways this is a dup of bug 323. The reason why it works for the non-inline floor case is because well there= is a rounding step that happens. The reason why -fexcess-precision=3Dstandard works (it is only implemented = for the C front-end) is because there rounding steps are now explict in the IR = and will use the 80bit fpu and then force the rounding back. The reason why -mfpmath=3Dsse works is instead of using x87, GCC will use t= he sse fpu implementation which is 64bit without excess precision. This is kinda not a bug, just you not understanding fpu and execess precisi= on. *** This bug has been marked as a duplicate of bug 323 ***=