9c: mind which CMP is used when handling constants

This commit is contained in:
Jacob Moody 2023-11-04 20:51:19 +00:00
parent fe53c0930e
commit 4cdad07b98

View file

@ -618,7 +618,7 @@ bcgen(Node *n, int true)
void void
boolgen(Node *n, int true, Node *nn) boolgen(Node *n, int true, Node *nn)
{ {
int o; int o, uns;
Prog *p1, *p2; Prog *p1, *p2;
Node *l, *r, nod, nod1; Node *l, *r, nod, nod1;
long curs; long curs;
@ -627,6 +627,7 @@ boolgen(Node *n, int true, Node *nn)
prtree(nn, "boolgen lhs"); prtree(nn, "boolgen lhs");
prtree(n, "boolgen"); prtree(n, "boolgen");
} }
uns = 0;
curs = cursafe; curs = cursafe;
l = n->left; l = n->left;
r = n->right; r = n->right;
@ -711,16 +712,18 @@ boolgen(Node *n, int true, Node *nn)
patch(p2, pc); patch(p2, pc);
goto com; goto com;
case OHI:
case OHS:
case OLO:
case OLS:
uns = 1;
/* fall through */
case OEQ: case OEQ:
case ONE: case ONE:
case OLE: case OLE:
case OLT: case OLT:
case OGE: case OGE:
case OGT: case OGT:
case OHI:
case OHS:
case OLO:
case OLS:
o = n->op; o = n->op;
if(true) if(true)
o = comrel[relindex(o)]; o = comrel[relindex(o)];
@ -735,7 +738,7 @@ boolgen(Node *n, int true, Node *nn)
boolgen(&nod, true, nn); boolgen(&nod, true, nn);
break; break;
} }
if(sconst(r)) { if(!uns && sconst(r)) {
regalloc(&nod, l, nn); regalloc(&nod, l, nn);
cgen(l, &nod); cgen(l, &nod);
gopcode(o, &nod, Z, r); gopcode(o, &nod, Z, r);