This is the mail archive of the
mailing list for the GCC project.
Re: Preprocessor macro for -mfpmath=sse ?
> On Sat, May 04, 2002 at 08:17:49PM -0700, Tim Prince wrote:
> > On Saturday 04 May 2002 18:14, Sylvain Pion wrote:
> > > On Fri, May 03, 2002 at 08:16:03PM -0700, Tim Prince wrote:
> > > > On Friday 03 May 2002 11:56, Sylvain Pion wrote:
> > > > > I have implemented some interval arithmetic code which has to work
> > > > > around the well known non-compliance (IEEE 754) issues of x86's
> > > > > floating point unit. I would like to get rid of these costly
> > > > > workarounds when I compile with -mfpmath=sse.
> > > > > Would you consider adding a preprocessor macro that I could test for ?
> > > >
> > > > I believe the pre-defined macros __SSE__ and __SSE2__ are intended for
> > > > such purposes.
> > >
> > > Where are they predefined ?
> > > I don't see these macros :
> > >
> > > ~> gcc -v -c -mfpmath=sse -msse foo.c
> > > Reading specs from [...]
> > > Thread model: single
> > > gcc version 3.2 20020502 (experimental)
> > > ./gcc/Linux_trunc/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2/cc1 -lang-c
> > > -quiet -v -iprefix
> > > ./gcc/Linux_trunc/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2/ -D__GNUC__=3
> > > -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -D__gnu_linux__
> > > -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux
> > > -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386
> > > -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__
> > > -D__tune_pentiumpro__ foo.c -quiet -dumpbase foo.c -mfpmath=sse -msse
> > > -version -o /tmp/ccFd2R6k.s
> > >
> > >
> > > I would expect to see -D__SSE__ or such here.
> > Both appear in gcc-3.1 when -mfpmath=sse is invoked together with
> > -march=pentium4. __SSE__ alone appears with -march=pentium4 instead.
> OK, but "-mfpmath=sse -msse2" is enough to generate SSE2 code, without the
> need for -march=pentium4 (I checked the assembly).
> The documentation of -mfpmath states : "you need to use -march=cpu-type, -msse
> or -msse2 switches to enable SSE extensions". (see the "or" ?)
> So I think that -msse2 should be enough to have __SSE2__, but currently it's
> not. Similarly for -msse => __SSE__.
This is bug, please just report it to gnats. I will try to fix it at monday
if time allows.
Concerning the -mfpmath yes, I guess there should be some wat to let
application know that the math is done in 64bit/32bit temporaries.
C99 defines macro for this purpose, so I guess we should simply use it,
but I am not sure whether changing the macro is classified as ABI change and
thus impossible (ie called functions compiled without -mfpmath can still
return more exact results than expected).
> While at it : how do I detect the use of "-mfpmath=sse,387" ?
> This option will define __SSE__, but I still need to have my workarounds in
> place, since gcc might use the i387...
> It would be nice to have a macro for this as well.
> BTW, are these __SSE__ and such macros documented somewhere ?
> I would expect something in the paragraph concerning -mfpmath.