]> Cypherpunks repositories - gostls13.git/commitdiff
fix float32 comparison. was doing l op l instead of l op r.
authorRuss Cox <rsc@golang.org>
Mon, 6 Jul 2009 16:05:33 +0000 (09:05 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 6 Jul 2009 16:05:33 +0000 (09:05 -0700)
R=ken
OCL=31190
CL=31190

src/cmd/8g/cgen.c

index 85cc9aca7defba086f4f93ad75aaf83687edbc29..8c90ad544ece214bf0e8c3f1a08a608df4d350de 100644 (file)
@@ -812,16 +812,17 @@ bgen(Node *n, int true, Prog *to)
                                cgen(nl, &tmp);
                                gins(AFUCOMPP, &tmp, &n2);
                        } else {
-                               // NOTE(rsc): This is wrong.
-                               // It's right for comparison but presumably all the
-                               // other ops have the same problem.  We need to
-                               // figure out what the right solution is, besides
-                               // tell people to use float64.
+                               // TODO(rsc): The moves back and forth to memory
+                               // here are for truncating the value to 32 bits.
+                               // This handles 32-bit comparison but presumably
+                               // all the other ops have the same problem.
+                               // We need to figure out what the right general
+                               // solution is, besides telling people to use float64.
                                tempalloc(&t1, types[TFLOAT32]);
                                tempalloc(&t2, types[TFLOAT32]);
                                cgen(nr, &t1);
                                cgen(nl, &t2);
-                               gmove(&t1, &tmp);
+                               gmove(&t2, &tmp);
                                gins(AFCOMFP, &t1, &tmp);
                                tempfree(&t2);
                                tempfree(&t1);