Gentoo Archives: gentoo-dev

From: Mike Gilbert <floppym@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] profiles/arch/amd64: add "-mfpmath=sse" to CFLAGS_x86
Date: Tue, 18 Oct 2022 15:55:19
Message-Id: CAJ0EP40a7gukjnN7vgFC+x32HovEjjXK25YnmxrHBdZNokpzFQ@mail.gmail.com
In Reply to: Re: [gentoo-dev] [PATCH] profiles/arch/amd64: add "-mfpmath=sse" to CFLAGS_x86 by David Seifert
1 On Tue, Oct 18, 2022 at 5:56 AM David Seifert <soap@g.o> wrote:
2 >
3 > On Tue, 2022-10-18 at 10:14 +0200, Ulrich Mueller wrote:
4 > > > > > > > On Tue, 18 Oct 2022, Mike Gilbert wrote:
5 > >
6 > > > Reference: https://gcc.gnu.org/wiki/x87note
7 > >
8 > > Which says:
9 > >
10 > > > ... the amount of worst-case error that could possibly happen using
11 > > > the x87 (with any amount of intermediate rounding) is at worst the
12 > > > same as true 64 or 32 bit arithmetic, and in practice is almost
13 > > > always
14 > > > better.
15 > >
16 > > and:
17 > >
18 > > > Note, however, that this greater repeatability comes at the cost of
19 > > > lost precision (i.e. SSE always gets the same precision because it
20 > > > always takes the equivalent of the x87's worst case: a forced round
21 > > > down at each step).
22 > >
23 > > So, it comes with a price, and I wonder if we shouldn't leave that
24 > > choice to the user, and go with the upstream GCC default?
25 > >
26 > > > -CFLAGS_x86="-m32"
27 > > > +CFLAGS_x86="-m32 -mfpmath=sse"
28 >
29 > -mfpmath=sse is already the default on amd64.
30
31 I have amended the first paragraph to make this more clear:
32
33 GCC uses x87 floating point instructions when building 32-bit x86
34 code by default. When building 64-bit code, SSE2 instructions are used
35 instead.