Re: [PATCH RFC] allow inline intrinsics for __ieee754_sqrt/f
Wilco Dijkstra <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <DB5PR08MB1030C5D96B2D4F233274628A83360@DB5PR08MB1030.eurprd08.prod.outlook.com> |
[email protected] wrote: >> You can replace all calls to it by sqrt, except for w_sqrt.c and wf_sqrt.c > > While -fno-builtin is still being used, this would just make the code slower though. No it would be faster even with -fno-builtin given that practically all uses of sqrt will execute the instruction, not the call. >> Or in the generic one call the builtin rather than __ieee754_sqrt based on a define. > > I looked at doing this, as the builtin seems nicer than inline asm, but the builtin for > GCC (not clang) also calls sqrt for negative numbers unless -fno-math-errno is used. I just tried: if (x >= 0) return __builtin_sqrt(x); That's faster than the existing code and also works fine with both -fmath-errno and -fno-builtin. >> But none of this will improve performance or codesize. > > Sure it does in my use case, otherwise I wouldn't be bothering 😉 That's not possible since sqrt function itself is never called unless the input is negative (which is a bug). Wilco