From 47165e1c2ccc0471349691cc92f64f81984b18c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigrid=20Solveig=20Hafl=C3=ADnud=C3=B3ttir?= Date: Tue, 9 May 2023 02:17:34 +0000 Subject: 5c, 7c: fix !x compilation when x is a negative float test case: void main(int, char **) { union { float f; u32int u; }x; x.u = 1U<<31; print("%d %d\n", !x.f, x.f == 0.0f); exits(nil); } --- sys/src/cmd/5c/cgen.c | 9 ++++++--- sys/src/cmd/7c/cgen.c | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'sys/src') diff --git a/sys/src/cmd/5c/cgen.c b/sys/src/cmd/5c/cgen.c index fdddfa8e9..26c038a38 100644 --- a/sys/src/cmd/5c/cgen.c +++ b/sys/src/cmd/5c/cgen.c @@ -729,9 +729,12 @@ boolgen(Node *n, int true, Node *nn) o = ONE; if(true) o = comrel[relindex(o)]; - if(typefd[n->type->etype]) { - gopcode(true ? o | BTRUE : o, nodfconst(0), &nod, Z); - } else + if(typefd[n->type->etype]){ + regalloc(&nod1, n, Z); + gmove(nodfconst(0.0), &nod1); + gopcode(true ? o | BTRUE : o, &nod1, &nod, Z); + regfree(&nod1); + }else gopcode(o, nodconst(0), &nod, Z); regfree(&nod); goto com; diff --git a/sys/src/cmd/7c/cgen.c b/sys/src/cmd/7c/cgen.c index 6f80f9f36..0be4aac58 100644 --- a/sys/src/cmd/7c/cgen.c +++ b/sys/src/cmd/7c/cgen.c @@ -738,8 +738,11 @@ boolgen(Node *n, int true, Node *nn) if(true) o = OEQ; if(typefd[n->type->etype]) { - gopcode(true ? o | BTRUE : o, nodfconst(0), &nod, Z); - } else + regalloc(&nod1, n, Z); + gmove(nodfconst(0.0), &nod1); + gopcode(true ? o | BTRUE : o, &nod1, &nod, Z); + regfree(&nod1); + }else gopcode(o, nodconst(0), &nod, Z); regfree(&nod); goto com; -- cgit v1.2.3