On Tue, Oct 22, 2024 at 6:19 PM LIU Hao <[email protected]> wrote:
>
> 在 2024-10-22 22:18, Jacek Caban 写道:
> > 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.
>
> Here's an updated patch.

A minor tweak would be like:

  if (__has_sse < 0) {
    int cpuInfo[4], infoType = 1;
    int o_flag, n_flag;

    __asm__ volatile ("pushfl\n\tpopl %0" : "=mr" (o_flag));
    n_flag = o_flag ^ 0x200000;
    __asm__ volatile ("pushl %0\n\tpopfl" : : "g" (n_flag));
    __asm__ volatile ("pushfl\n\tpopl %0" : "=mr" (n_flag));
    if (n_flag == o_flag) {
      __has_sse = 0;
      return 0;
    }

    __asm__ __volatile__ (
      "cpuid"
      : "=a" (cpuInfo[0]), "=b" (cpuInfo[1]), "=c" (cpuInfo[2]),
      "=d" (cpuInfo[3])
      : "a" (infoType));
    __has_sse = (cpuInfo[3] & 0x2000000);
  }
  return __has_sse;

--
O.S.


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

Reply via email to