On 21.10.2024 16:50, LIU Hao wrote:
在 2024-10-21 19:11, LIU Hao 写道:
BTW, affected functions seem to be available in modern msvcrt (msvcr120 and UCRT), so another solution for the bug would be to move those function out of mingwex and use implementation provided by OS when possible.

I can take a look later.

Attached is a patch for skipping the run-time check where SSE must exist, for example, on Pentium 3 or on x86-64.


To elaborate on use of __SSE__ macro: it will be indeed mostly do the right thing. On x86_64, it will always be present, so that's fine. On 32-bit x86, it will vary depending on compiler and command line arguments. It may be explicitly enabled or disabled with CFLAG options like -msse/-mno-sse. If it's enabled, the compiler is free to use it for other parts of crt, so doing runtime checks is indeed not bringing any compatibility benefits. As such, your solution looks fine to me.


Compilers seem to have different defaults on 32-bit targets: Clang enables it by default, while GCC does not. While having different crt behavior depending on the compiler is generally something we should avoid, in this case it just reflects reality, so that seems okay.


Style-wise, I would perhaps prefer a solution that uses fewer #ifdefs. We could for example change __mingw_has_sse to always return true when it's defined. It would limit optimization opportunities for the compiler, so perhaps we could have it in a header and make it a trivial inline in case __SSE__ is defined? Anyway, the current patch matches how similar things are done in mingw-w64, so I won't insist on that.


Even with that patch, the original patch caching cpuid result would still be beneficial for cases when __SSE__ is not defined.


The Microsoft implementation can't be used, as explained in e5d1fe451b81db3134d7ba70ff39d0a1b6c91b36.


I missed that, it's good to know.


Thanks,

Jacek

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to