ref: 4cdad07b986ada742ae0198e2bea4208685b500a
parent: fe53c0930e8595a2e8b5aa71e907a1f2bec6059b
author: Jacob Moody <moody@posixcafe.org>
date: Sat Nov 4 16:51:19 EDT 2023
9c: mind which CMP is used when handling constants
--- a/sys/src/cmd/9c/cgen.c
+++ b/sys/src/cmd/9c/cgen.c
@@ -618,7 +618,7 @@
void
boolgen(Node *n, int true, Node *nn)
{
- int o;
+ int o, uns;
Prog *p1, *p2;
Node *l, *r, nod, nod1;
long curs;
@@ -627,6 +627,7 @@
prtree(nn, "boolgen lhs");
prtree(n, "boolgen");
}
+ uns = 0;
curs = cursafe;
l = n->left;
r = n->right;
@@ -711,6 +712,12 @@
patch(p2, pc);
goto com;
+ case OHI:
+ case OHS:
+ case OLO:
+ case OLS:
+ uns = 1;
+ /* fall through */
case OEQ:
case ONE:
case OLE:
@@ -717,10 +724,6 @@
case OLT:
case OGE:
case OGT:
- case OHI:
- case OHS:
- case OLO:
- case OLS:
o = n->op;
if(true)
o = comrel[relindex(o)];
@@ -735,7 +738,7 @@
boolgen(&nod, true, nn);
break;
}
- if(sconst(r)) {
+ if(!uns && sconst(r)) {
regalloc(&nod, l, nn);
cgen(l, &nod);
gopcode(o, &nod, Z, r);