This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: Expand finite() as inline i386 asm


On 2/1/07, Richard Henderson <rth@redhat.com> wrote:

On Wed, Jan 31, 2007 at 04:58:32PM -0800, Richard Henderson wrote:
>   isfinite(d) => islessequal(fabs(d), DBL_MAX)

Oh, and I should note that this doesn't require *any* optabs,
since its completely generic.

Please consider soft-float targets. If we want to implement this transformation as part of fold_builtin_classify() [builtins.c] that would penalize soft-float targets too much. We would trade one call to isinf() with calls to __unorddf2(), __ledf2 load of DBL_MAX and fabs() bit manipulation. This transformation is worth only for isnan() where we trade call to isnan() to the call to __unorddf2().

Due to this fact, we have to implement this transformation with optab.

BTW: I have done some measurements for different implementations, and
for targets without fucomi(p) insn, fxam is faster that fabs/fucompp
sequence. SSE and fcomi targets should implement isinf() as you
proposed.

Measurements were done using following code:
--cut here--
int test(double a)
{
 //return 1.0;
 //return isinf(a);
 //return __builtin_isgreater(fabs(a), 1.79769313486231470e+308);
}

int main()
{
 double d;
 int s = 0;

 for (d = 0.0; d < 1e8; d += 1.0)
   s += test (d);

 return s;
}
--cut here--

gcc -O2 -fomit-frame-pointer (and uncommenting relevant line):

base 0m0.780s
fxam 0m0.888s
fabs/fucompp 0m1.008s

gcc -O2 -fomit-frame-pointer -march=i686

base 0m0.776s
fxam 0m0.840s
fabs/fucomip 0m0.784s

gcc -O2 -fomit-frame-pointer -march=i686 -msse2 -mfpmath=sse

base 0m0.780s
sibcall isinf() 0m1.108s
andpd/ucomisd 0m0.756s

Uros.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]