Use fabs[f]() instead of bit fiddling for setting absolute values.
This makes little difference in float precision, but in double precision gives a speedup of about 30% on amd64 (A64 CPU) and i386 (A64). This depends on fabs[f]() being inline and efficient. The bit fiddling (or any use of SET_HIGH_WORD(), which libm does too much because it was best on old 32-bit machines) always causes packing overheads and sometimes causes stalls in the packing, since it operates on only part of a variable in the double precision case. It apparently did cause stalls in a critical path here.
This commit is contained in:
parent
c0c7ddd3a8
commit
42ee187c3c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=177751
@ -60,8 +60,8 @@ __ieee754_hypot(double x, double y)
|
||||
GET_HIGH_WORD(hb,y);
|
||||
hb &= 0x7fffffff;
|
||||
if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
|
||||
SET_HIGH_WORD(a,ha); /* a <- |a| */
|
||||
SET_HIGH_WORD(b,hb); /* b <- |b| */
|
||||
a = fabs(a);
|
||||
b = fabs(b);
|
||||
if((ha-hb)>0x3c00000) {return a+b;} /* x/y > 2**60 */
|
||||
k=0;
|
||||
if(ha > 0x5f300000) { /* a>2**500 */
|
||||
|
@ -30,8 +30,8 @@ __ieee754_hypotf(float x, float y)
|
||||
GET_FLOAT_WORD(hb,y);
|
||||
hb &= 0x7fffffff;
|
||||
if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
|
||||
SET_FLOAT_WORD(a,ha); /* a <- |a| */
|
||||
SET_FLOAT_WORD(b,hb); /* b <- |b| */
|
||||
a = fabsf(a);
|
||||
b = fabsf(b);
|
||||
if((ha-hb)>0xf000000) {return a+b;} /* x/y > 2**30 */
|
||||
k=0;
|
||||
if(ha > 0x58800000) { /* a>2**50 */
|
||||
|
Loading…
Reference in New Issue
Block a user