This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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 RFC] allow inline intrinsics for __ieee754_sqrt/f


jon@beniston.com 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
    

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