From 70249d8b64fcd3c19735b6c1a4c70175774f1cdd Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 3 Jul 2023 17:51:05 -0400 Subject: [PATCH] In bins, promote to smallest common int type instead of i32 --- src/builtins/grade.h | 35 ++++++++++++++++++++--------------- src/singeli/src/bins.singeli | 1 + 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/builtins/grade.h b/src/builtins/grade.h index 4b905100..10e17f13 100644 --- a/src/builtins/grade.h +++ b/src/builtins/grade.h @@ -378,6 +378,10 @@ B GRADE_CAT(c2)(B t, B w, B x) { u8 we = TI(w,elType); usz wia = IA(w); u8 xe = TI(x,elType); usz xia = IA(x); + if (wia==0 | xia==0) { + Arr* ra=allZeroes(xia); arr_shCopy(ra, x); + decG(w); decG(x); return taga(ra); + } if (wia>I32_MAX-10) thrM(GRADE_CHR": 𝕨 too big"); u8 fl = GRADE_UD(fl_asc,fl_dsc); @@ -391,19 +395,16 @@ B GRADE_CAT(c2)(B t, B w, B x) { if (LIKELY(wexe? we : xe; + if (ze==el_bit) ze = el_i8; + if (ze > we) { switch (ze) { default:UD; case el_i8:w=toI8Any(w);break; case el_i16:w=toI16Any(w);break; case el_i32:w=toI32Any(w);break; case el_f64:w=toF64Any(w);break; } } + if (ze > xe) { switch (ze) { default:UD; case el_i8:x=toI8Any(x);break; case el_i16:x=toI16Any(x);break; case el_i32:x=toI32Any(x);break; case el_f64:x=toF64Any(x);break; } } + we = ze; + #else + if (!elInt(we) | !elInt(xe)) goto gen; w=toI32Any(w); x=toI32Any(x); + #endif } else { for (u64 i=0; i 0} def T = i8; def I = u8 def lt = if (up) <; else > def pre = (if (up) minvalue else maxvalue){T}