[Bug 294692] [PATCH] lib/msun: Replaced manual checks with isnan()
[email protected] Tue, 21 Apr 2026 23:41:58 +0000
| Newsgroups | gmane.os.freebsd.devel.standards |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D294692 --- Comment #1 from Steve Kargl <[email protected]> --- Jesus, this looks okay to me. But, I do wonder about one issue and have one suggestion. Issue: All of the bitwise expressions that have been replaced worked even if a user compiled libm with -ffast-math. I suspect the new changes will be optimized out. I don't know if we need to be paranoid about this or not; worse yet, I do=20 not know how to warn users to be careful with compiler options. Suggestion: In the changed routines, we either assign parameters to internal variables or directly access the bits before the isnan() tests. For example, double nextafter(double x, double y) { volatile double t; int32_t hx,hy,ix,iy; u_int32_t lx,ly; EXTRACT_WORDS(hx,lx,x); EXTRACT_WORDS(hy,ly,y); ix =3D hx&0x7fffffff; /* |x| */ iy =3D hy&0x7fffffff; /* |y| */ - if(((ix>=3D0x7ff00000)&&((ix-0x7ff00000)|lx)!=3D0) || /* x is nan= */ - ((iy>=3D0x7ff00000)&&((iy-0x7ff00000)|ly)!=3D0)) /* y is nan= */ + if(isnan(x) || isnan(y)) /* x or y is nan */ return x+y; if(x=3D=3Dy) return y; /* x=3Dy, return y */ if((ix|lx)=3D=3D0) { /* x =3D=3D 0 */ INSERT_WORDS(x,hy&0x80000000,1); /* return +-minsubnormal */ You can move the isnan() test to before EXTRACT_WORDS() in the above as well as the 'x =3D=3D y' test. That is, extract the bits when we need them. --=20 You are receiving this mail because: You are the assignee for the bug.=