summaryrefslogtreecommitdiff
path: root/src/cmd/9g/cgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/9g/cgen.c')
-rw-r--r--src/cmd/9g/cgen.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/cmd/9g/cgen.c b/src/cmd/9g/cgen.c
index a8d628f43..6bb44f547 100644
--- a/src/cmd/9g/cgen.c
+++ b/src/cmd/9g/cgen.c
@@ -1267,12 +1267,21 @@ bgen(Node *n, int true, int likely, Prog *to)
l = &n1;
r = &n2;
gins(optoas(OCMP, nr->type), l, r);
-
- // TODO(minux): determine the reason for failed test/floatcmp.go.
- // we might need to specially handle floating point comparisons.
- /*if(isfloat[nr->type->etype] && (n->op == OEQ || n->op == ONE)) {
- } else*/
+ if(isfloat[nr->type->etype] && (n->op == OLE || n->op == OGE)) {
+ // To get NaN right, must rewrite x <= y into separate x < y or x = y.
+ switch(n->op) {
+ case OLE:
+ a = OLT;
+ break;
+ case OGE:
+ a = OGT;
+ break;
+ }
patch(gbranch(optoas(a, nr->type), nr->type, likely), to);
+ patch(gbranch(optoas(OEQ, nr->type), nr->type, likely), to);
+ } else {
+ patch(gbranch(optoas(a, nr->type), nr->type, likely), to);
+ }
regfree(&n1);
regfree(&n2);
break;