delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/11/16/15:34:44

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <3FB7E550.914CB006@phekda.freeserve.co.uk>
Date: Sun, 16 Nov 2003 21:00:00 +0000
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: djgpp: djgpp/include/math.h
References: <200311161926 DOT hAGJQrWq025150 AT speedy DOT ludd DOT luth DOT se>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

ams AT ludd DOT luth DOT se wrote:
> 
> According to cvs-ams AT delorie DOT com:
> > Update by cvs id: ams
> > Update of /cvs/djgpp/djgpp/include
> >
> > Modified Files:
> >       math.h
> > Log Message:
> > Changed FP_ values and isfinite() macro for better optimisation.
> >
> >
> > ===================================================================
> > RCS file: /cvs/djgpp/djgpp/include/math.h,v
> > retrieving revision 1.11
> > retrieving revision 1.12
> > diff -p -2 -r1.11 -r1.12
> > *** djgpp/include/math.h      30 Oct 2003 20:48:43 -0000      1.11
> > --- djgpp/include/math.h      16 Nov 2003 10:44:35 -0000      1.12
> ...
> > *** 112,121 ****
> >                      __fpclassifyld(x))
> >
> > ! #define isfinite(x) (fpclassify(x)==FP_NORMAL || \
> > !                      fpclassify(x)==FP_SUBNORMAL || \
> > !                      fpclassify(x)==FP_ZERO)
> > ! #define isinf(x)    (fpclassify(x)==FP_INFINITE)
> > ! #define isnan(x)    (fpclassify(x)==FP_NAN)
> > ! #define isnormal(x) (fpclassify(x)==FP_NORMAL)
> >
> >   int         __fpclassifyf(float) __attribute__((const));
> > --- 112,119 ----
> >                      __fpclassifyld(x))
> >
> > ! #define isfinite(x)   ((fpclassify(x) & (FP_NORMAL|FP_SUBNORMAL|FP_ZERO)) != 0)
> > ! #define isinf(x)      (fpclassify(x)==FP_INFINITE)
> > ! #define isnan(x)      (fpclassify(x)==FP_NAN)
> > ! #define isnormal(x)   (fpclassify(x)==FP_NORMAL)
> 
> Ehum... Late, but perhaps I should change the other is*() to the
> format "fpclassify(x) & FP_<something>) != 0" too?
> 
> 1. Consistent.

I thought the previous change was so that there weren't three expansions of
the fpclassify macro for isfinite? isinf, isnan and isnormal don't have that
problem.

So the only consistency is with the way you test the FP_* flags. Directly
comparing the constants seems clearer to me than doing & <something> != 0, if
I'm quickly looking through the header file. (Easier for me to parse.)

> 2. Might help gcc optimise if the coder does "if( isinf(x) ||
> isnan(x) ) ..." (I haven't done any tests and I don't plan to.)

If you don't test it, how do you know whether it will have any effect?

I don't see that there's any point changing the other is* macros, to be
honest.

Bye, Rich =]

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]

"You can't evaluate a man by logic alone." -- McCoy, "I, Mudd", Star Trek

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019