]> gitweb.factorcode.org Git - factor.git/commitdiff
math.vectors.simd.intrinsics: better fake vgetmask
authorJoe Groff <arcata@gmail.com>
Sat, 12 Nov 2011 23:37:25 +0000 (15:37 -0800)
committerJoe Groff <arcata@gmail.com>
Mon, 14 Nov 2011 00:10:22 +0000 (16:10 -0800)
More accurate simulacrum of PMOVMSKB/MOVMSKPS/MOVMSKPD for non-intrinsic definition

basis/math/vectors/simd/intrinsics/intrinsics.factor

index 5a2cbe2fe86411f673be7b3f82cecbc949a130ba..b8dbe6d1bdaa103f7d59aa22d8841d51a71fd3f9 100644 (file)
@@ -158,6 +158,9 @@ GENERIC: native/ ( x y -- x/y )
 M: integer native/ /i ; inline
 M: float native/ /f ; inline
 
+: ((vgetmask)) ( a rep -- b )
+    0 [ [ 1 shift ] [ zero? 0 1 ? ] bi* bitor ] bitwise-components-reduce* ; inline
+
 PRIVATE>
 
 SIMD-INTRINSIC: (simd-v+)                ( a b rep -- c ) [ + ] components-2map ;
@@ -262,7 +265,9 @@ SIMD-INTRINSIC: (simd-vunordered?)       ( a b rep -- c )
 SIMD-INTRINSIC: (simd-vany?)             ( a   rep -- ? ) [ bitor  ] bitwise-components-reduce zero? not ;
 SIMD-INTRINSIC: (simd-vall?)             ( a   rep -- ? ) [ bitand ] bitwise-components-reduce zero? not ;
 SIMD-INTRINSIC: (simd-vnone?)            ( a   rep -- ? ) [ bitor  ] bitwise-components-reduce zero?     ;
-SIMD-INTRINSIC: (simd-vgetmask)          ( a   rep -- n ) 0 [ [ 1 shift ] [ zero? 0 1 ? ] bi* bitor ] bitwise-components-reduce* ;
+SIMD-INTRINSIC: (simd-vgetmask)          ( a   rep -- n )
+    dup { float-4-rep double-2-rep } member?
+    [ ((vgetmask)) ] [ drop uchar-16-rep ((vgetmask)) ] if ;
 SIMD-INTRINSIC: (simd-v>float)           ( a   rep -- c )
     [ [ >rep-array ] [ rep-length ] bi [ >float ] ]
     [ >float-vector-rep <rep-array> ] bi unrolled-map-as-unsafe underlying>> ;