define single ICMP

This commit is contained in:
dzaima 2023-05-10 22:24:59 +03:00
parent 4b0cd3217f
commit aa68ed0730
2 changed files with 5 additions and 8 deletions

View File

@ -1,7 +1,6 @@
#include "../core.h"
#include "../utils/calls.h"
#define CMP(W,X) ({ AUTO wt = (W); AUTO xt = (X); (wt>xt?1:0)-(wt<xt?1:0); })
NOINLINE i32 compareF(B w, B x) {
if (isNum(w) & isC32(x)) return -1;
if (isC32(w) & isNum(x)) return 1;
@ -23,7 +22,7 @@ NOINLINE i32 compareF(B w, B x) {
ur wr=RNK(w); usz* wsh=SH(w);
ur xr=RNK(x); usz* xsh=SH(x);
i32 rc = CMP(wr, xr);
i32 rc = ICMP(wr, xr);
ur rr = wr<xr? wr : xr;
i32 ri = 0; // matching shape tail
usz rm = 1;
@ -34,14 +33,14 @@ NOINLINE i32 compareF(B w, B x) {
if (ri<rr) {
usz wm = wsh[wr-1-ri];
usz xm = xsh[xr-1-ri];
rc = CMP(wm, xm);
rc = ICMP(wm, xm);
rm*= wm<xm? wm : xm;
}
usz wia = IA(w);
usz xia = IA(x);
if (wia==0 || xia==0) {
i32 rc2 = CMP(wia, xia);
i32 rc2 = ICMP(wia, xia);
return rc2!=0? rc2 : rc;
}
@ -53,7 +52,6 @@ NOINLINE i32 compareF(B w, B x) {
}
return rc;
}
#undef CMP
NOINLINE bool atomEqualF(B w, B x) {
if (TY(w)!=TY(x)) return false;

View File

@ -248,7 +248,7 @@ void noop_visit(Value* x);
#define VISIT_SHAPE(X)
#endif
#define CMP(W,X) ({ AUTO wt = (W); AUTO xt = (X); (wt>xt?1:0)-(wt<xt?1:0); })
#define ICMP(W,X) ({ AUTO wt = (W); AUTO xt = (X); (wt>xt?1:0)-(wt<xt?1:0); })
SHOULD_INLINE i32 compareFloat(f64 w, f64 x) {
if (RARE(w!=w || x!=x)) return (w!=w) - (x!=x);
#if __x86_64__
@ -260,10 +260,9 @@ SHOULD_INLINE i32 compareFloat(f64 w, f64 x) {
NOINLINE i32 compareF(B w, B x);
static i32 compare(B w, B x) { // doesn't consume; -1 if w<x, 1 if w>x, 0 if w≡x
if (isNum(w) & isNum(x)) return compareFloat(o2fG(w), o2fG(x));
if (isC32(w) & isC32(x)) return CMP(o2cG(w), o2cG(x));
if (isC32(w) & isC32(x)) return ICMP(o2cG(w), o2cG(x));
return compareF(w, x);
}
#undef CMP
NOINLINE bool atomEqualF(B w, B x);
static bool atomEqual(B w, B x) { // doesn't consume