* check also for XGETBV support, resolves problem reported by Pierre

This commit is contained in:
florian 2023-11-20 22:54:55 +01:00
parent cbcc7c8d35
commit b164817e18

View File

@ -1250,7 +1250,7 @@ const
{$define FPC_SYSTEM_HAS_FPC_CPUINIT} {$define FPC_SYSTEM_HAS_FPC_CPUINIT}
procedure fpc_cpuinit; procedure fpc_cpuinit;
var var
_eax,_ebx,_ecx : dword; _eax,_ebx,cpuid1_ecx : dword;
begin begin
{ don't let libraries influence the FPU cw set by the host program } { don't let libraries influence the FPU cw set by the host program }
if IsLibrary then if IsLibrary then
@ -1267,26 +1267,30 @@ procedure fpc_cpuinit;
if _eax>=7 then if _eax>=7 then
begin begin
asm asm
movl $1,%eax
xorl %ecx,%ecx xorl %ecx,%ecx
.byte 0x0f,0x01,0xd0 { xgetbv } cpuid
movl %eax,_eax movl %ecx,cpuid1_ecx
end; end;
if (_eax and 6)=6 then { XGETBV support? }
if (cpuid1_ecx and $8000000)<>0 then
begin begin
asm asm
movl $1,%eax
xorl %ecx,%ecx xorl %ecx,%ecx
cpuid .byte 0x0f,0x01,0xd0 { xgetbv }
movl %ecx,_ecx movl %eax,_eax
end; end;
has_avx_support:=(_ecx and $10000000)<>0; if (_eax and 6)=6 then
asm begin
movl $7,%eax has_avx_support:=(cpuid1_ecx and $10000000)<>0;
xorl %ecx,%ecx asm
cpuid movl $7,%eax
movl %ebx,_ebx xorl %ecx,%ecx
end; cpuid
has_avx2_support:=(_ebx and $20)<>0; movl %ebx,_ebx
end;
has_avx2_support:=(_ebx and $20)<>0;
end;
end; end;
end; end;
end; end;