The enough help you need is, in the implementation of the library function #if X86 #if GCC etc and then the assembly for each case, otherwise the slow but standard implementation. And that's one file, the code never to be directly used but by function name. It's already done this way in the current libraries for a lot processor specific stuff.
There are many examples where compilers special-case what is in a library. For example, compilers know they do not have to call strlen every time through this loop: