summaryrefslogtreecommitdiff
path: root/sys/src/cmd/5c
diff options
context:
space:
mode:
authorSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2023-05-09 02:17:34 +0000
committerSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2023-05-09 02:17:34 +0000
commit47165e1c2ccc0471349691cc92f64f81984b18c5 (patch)
tree6e523cfb8660f7fa6bd2bf3d693328786142aeef /sys/src/cmd/5c
parent090af6255bebf0129c891116b53b31808fe49dc7 (diff)
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); }
Diffstat (limited to 'sys/src/cmd/5c')
-rw-r--r--sys/src/cmd/5c/cgen.c9
1 files changed, 6 insertions, 3 deletions
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;