cpu.x86: Fix the popcnt? word alien-assembly. XOR the return-reg RAX before calling BT/BSET because XOR clears the CF and the whole thing becomes a no-op. Change popcnt instruction to opt-out rather than opt-in. Fixes #663.

db4
Doug Coleman 2012-09-18 17:14:31 -07:00
parent cfa87365e3
commit 9ebd6c11ad
1 changed files with 2 additions and 2 deletions

View File

@ -88,13 +88,13 @@ MEMO: sse-version ( -- n )
bool { } cdecl [ bool { } cdecl [
return-reg 1 MOV return-reg 1 MOV
CPUID CPUID
ECX 23 BT
return-reg dup XOR return-reg dup XOR
ECX 23 BT
return-reg SETB return-reg SETB
] alien-assembly ; ] alien-assembly ;
MEMO: enable-popcnt? ( -- ? ) MEMO: enable-popcnt? ( -- ? )
popcnt? "enable-popcnt" get and ; popcnt? "disable-popcnt" get not and ;
[ { sse-version enable-popcnt? } [ reset-memoized ] each ] [ { sse-version enable-popcnt? } [ reset-memoized ] each ]
"cpu.x86.features" add-startup-hook "cpu.x86.features" add-startup-hook