Mail Archives: djgpp-workers/2003/11/16/15:34:44
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 -