diff --git a/src/builtins/scan.c b/src/builtins/scan.c index 74871035..617c3457 100644 --- a/src/builtins/scan.c +++ b/src/builtins/scan.c @@ -1,6 +1,9 @@ #include "../core.h" #include "../utils/mut.h" #include "../builtins.h" +#include +#define F64_MIN -INFINITY +#define F64_MAX INFINITY #if !USE_VALGRIND static u64 vg_rand(u64 x) { return x; } @@ -104,10 +107,11 @@ B scan_add_bool(B x, u64 ia) { // consumes x MM_CASE(i8 ,NAME,C,I8_##INIT ) \ MM_CASE(i16,NAME,C,I16_##INIT) \ MM_CASE(i32,NAME,C,I32_##INIT) \ + MM_CASE(f64,NAME,C,F64_##INIT) \ } \ decG(x); return FL_SET(r, fl_##ORD); -static B scan_min_int(B x, u8 xe, usz ia) { MINMAX(min,<,MAX,dsc) } -static B scan_max_int(B x, u8 xe, usz ia) { MINMAX(max,>,MIN,asc) } +static B scan_min_num(B x, u8 xe, usz ia) { MINMAX(min,<,MAX,dsc) } +static B scan_max_num(B x, u8 xe, usz ia) { MINMAX(max,>,MIN,asc) } #undef MM_CASE #undef MINMAX #undef MINMAX_SCAN @@ -145,8 +149,8 @@ B scan_c1(Md1D* d, B x) { B f = d->f; if (xe==el_i16) { i16* xp=i16any_ptr(x); i32* rp; B r=m_i32arrv(&rp, ia); i32 c=0; for (usz i=0; ish{4b1110,sh{4b2200,a}}} +} def avx2_scan_idem{T, op} = { def m = 1 << (width{T}-1) avx2_scan_idem{T, op, (if (match{op,min}) m-1; else -m)} @@ -65,6 +70,8 @@ def avx2_scan_idem{T, op} = { 'avx2_scan_max_i16' = avx2_scan_idem{i16, max} 'avx2_scan_min_i32' = avx2_scan_idem{i32, min} 'avx2_scan_max_i32' = avx2_scan_idem{i32, max} +'avx2_scan_min_f64' = avx2_scan_idem{f64, min, 'F64_MAX'} +'avx2_scan_max_f64' = avx2_scan_idem{f64, max, 'F64_MIN'} # Associative scan avx2_scan_assoc_0{T, op}(x:*T, r:*T, len:u64, init:T) : void = {