From 9ebd6c11adf07d8b74e20603321367bfa0d218dd Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 18 Sep 2012 17:14:31 -0700 Subject: [PATCH] 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. --- basis/cpu/x86/features/features.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/cpu/x86/features/features.factor b/basis/cpu/x86/features/features.factor index 7c4026bb6b..8be47f088c 100644 --- a/basis/cpu/x86/features/features.factor +++ b/basis/cpu/x86/features/features.factor @@ -88,13 +88,13 @@ MEMO: sse-version ( -- n ) bool { } cdecl [ return-reg 1 MOV CPUID - ECX 23 BT return-reg dup XOR + ECX 23 BT return-reg SETB ] alien-assembly ; MEMO: enable-popcnt? ( -- ? ) - popcnt? "enable-popcnt" get and ; + popcnt? "disable-popcnt" get not and ; [ { sse-version enable-popcnt? } [ reset-memoized ] each ] "cpu.x86.features" add-startup-hook