diff --git a/basis/compiler/cfg/instructions/instructions.factor b/basis/compiler/cfg/instructions/instructions.factor index 703294e394..1c445605d2 100644 --- a/basis/compiler/cfg/instructions/instructions.factor +++ b/basis/compiler/cfg/instructions/instructions.factor @@ -224,6 +224,11 @@ FOLDABLE-INSN: ##bit-count def: dst/int-rep use: src/int-rep ; +FOLDABLE-INSN: ##bit-test +def: dst/tagged-rep +use: src1/int-rep src2/int-rep +temp: temp/int-rep ; + ! Float arithmetic FOLDABLE-INSN: ##add-float def: dst/double-rep diff --git a/basis/compiler/cfg/intrinsics/intrinsics.factor b/basis/compiler/cfg/intrinsics/intrinsics.factor index 7d744e7496..24b7e05bdc 100644 --- a/basis/compiler/cfg/intrinsics/intrinsics.factor +++ b/basis/compiler/cfg/intrinsics/intrinsics.factor @@ -138,5 +138,10 @@ ERROR: inline-intrinsics-not-supported word quot ; { math.bitwise.private:fixnum-bit-count [ drop [ ^^bit-count ] unary-op ] } } enable-intrinsics ; +: enable-bit-test ( -- ) + { + { math.integers.private:fixnum-bit? [ drop [ ^^bit-test ] binary-op ] } + } enable-intrinsics ; + : emit-intrinsic ( node word -- ) "intrinsic" word-prop call( node -- ) ; diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index a488a36e7f..11175ec366 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -181,6 +181,7 @@ CODEGEN: ##not %not CODEGEN: ##neg %neg CODEGEN: ##log2 %log2 CODEGEN: ##bit-count %bit-count +CODEGEN: ##bit-test %bit-test CODEGEN: ##copy %copy CODEGEN: ##tagged>integer %tagged>integer CODEGEN: ##add-float %add-float diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index 6cd42c5752..7ab49574aa 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -271,6 +271,7 @@ HOOK: %not cpu ( dst src -- ) HOOK: %neg cpu ( dst src -- ) HOOK: %log2 cpu ( dst src -- ) HOOK: %bit-count cpu ( dst src -- ) +HOOK: %bit-test cpu ( dst src1 src2 temp -- ) HOOK: %copy cpu ( dst src rep -- ) diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index aa9d7683d4..9d67c9339d 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -764,6 +764,12 @@ M: x86 immediate-bitwise? ( n -- ? ) enable-min/max enable-log2 +M:: x86 %bit-test ( dst src1 src2 temp -- ) + src1 src2 BT + dst temp \ CMOVB (%boolean) ; + +enable-bit-test + : check-sse ( -- ) "Checking for multimedia extensions... " write flush sse-version diff --git a/core/math/integers/integers.factor b/core/math/integers/integers.factor index 98ca157b72..7aae3c5362 100644 --- a/core/math/integers/integers.factor +++ b/core/math/integers/integers.factor @@ -53,7 +53,7 @@ M: fixnum bitnot fixnum-bitnot ; inline : fixnum-bit? ( x n -- ? ) { fixnum fixnum } declare - dup 0 >= [ neg shift even? not ] [ 2drop f ] if ; inline + dup 0 >= [ neg shift even? not ] [ 2drop f ] if ; M: fixnum bit? integer>fixnum-strict fixnum-bit? ; inline