Page MenuHomeFreeBSD

lib/msun amd64: use AVX FMA instructions for fma(3) and fmaf(3) when available
ClosedPublic

Authored by kib on Sep 6 2026, 6:02 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 17, 11:25 AM
Unknown Object (File)
Fri, Oct 16, 11:11 PM
Unknown Object (File)
Fri, Oct 16, 10:45 PM
Unknown Object (File)
Fri, Oct 16, 6:32 PM
Unknown Object (File)
Fri, Oct 16, 11:25 AM
Unknown Object (File)
Fri, Oct 16, 11:23 AM
Unknown Object (File)
Wed, Oct 14, 6:24 AM
Unknown Object (File)
Sun, Oct 11, 3:57 AM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Sep 6 2026, 6:02 AM
This revision is now accepted and ready to land.Sep 6 2026, 3:31 PM

There could be some performance issues related to the SSE/AVX transition state machine, but checking the Intel Software Optimization Manual, it seems like executing 128 bit AVX instructions seems unproblematic in any steady-state scenario.

Brilliant work. Thanks!

Put added symbols into private namespace.
It does not matter for shared library, but helps static linking.

This revision now requires review to proceed.Sep 6 2026, 9:17 PM

Switch to use libc/amd64/string ARCHLEVEL infra to control the selection.

Oh yeah, using the archlevel framework sounds like a good idea! I didn't even think about that, as it's specific to libc. Other libm functions may profit in the future.

In D59462#1365021, @fuz wrote:

Oh yeah, using the archlevel framework sounds like a good idea! I didn't even think about that, as it's specific to libc. Other libm functions may profit in the future.

Do you have any notes about the updated patch?

BTW, I was not able to come up with a C expression that can be used to initialize the function table, so I resorted to filling it in assembler same as is done for strings.

Add kargl@ patch from PR 298260

In D59462#1365088, @kib wrote:
In D59462#1365021, @fuz wrote:

Oh yeah, using the archlevel framework sounds like a good idea! I didn't even think about that, as it's specific to libc. Other libm functions may profit in the future.

Do you have any notes about the updated patch?

BTW, I was not able to come up with a C expression that can be used to initialize the function table, so I resorted to filling it in assembler same as is done for strings.

Oh the patch is fine, I just forgot to hit “approve.” I don't think the table can be initialised in C. I designed it this way to reduce the amounts of relocations and the table size, and I don't think C wants to do this stuff. We could do an inline assembly macro to build the table in C if you like.

This revision is now accepted and ready to land.Sep 8 2026, 7:45 AM