ref: 80d1d7baa6c85b767dc343c15e2949b02a16cad3
parent: 5b5eb709ac2e5b2e22796710d47daa26d7a240f4
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon May 8 22:17:34 EDT 2023
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);
}
--- a/sys/src/cmd/5c/cgen.c
+++ b/sys/src/cmd/5c/cgen.c
@@ -729,9 +729,12 @@
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;
--- a/sys/src/cmd/7c/cgen.c
+++ b/sys/src/cmd/7c/cgen.c
@@ -738,8 +738,11 @@
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;
--
⑨