]> Cypherpunks repositories - gostls13.git/commitdiff
8g: use FCHS, not FMUL, for minus float
authorRuss Cox <rsc@golang.org>
Fri, 27 Aug 2010 18:02:00 +0000 (14:02 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 27 Aug 2010 18:02:00 +0000 (14:02 -0400)
Fixes #1052.

R=ken2
CC=golang-dev
https://golang.org/cl/2055041

src/cmd/8g/cgen.c
src/cmd/8g/gsubr.c

index 519907aa6d07bd0ede1b0625ac627851896f2578..f054a89f40e67be09b6defa8cef265fe07b793f2 100644 (file)
@@ -392,23 +392,16 @@ uop:      // unary
        gmove(&n1, res);
        return;
 
-flt:   // floating-point.  387 (not SSE2) to interoperate with 6c
+flt:   // floating-point.  387 (not SSE2) to interoperate with 8c
        nodreg(&f0, nl->type, D_F0);
        nodreg(&f1, n->type, D_F0+1);
        if(nr != N)
                goto flt2;
 
-       if(n->op == OMINUS) {
-               nr = nodintconst(-1);
-               convlit(&nr, n->type);
-               n->op = OMUL;
-               goto flt2;
-       }
-
        // unary
        cgen(nl, &f0);
        if(n->op != OCONV && n->op != OPLUS)
-               gins(foptoas(n->op, n->type, 0), &f0, &f0);
+               gins(foptoas(n->op, n->type, 0), N, N);
        gmove(&f0, res);
        return;
 
index 6890c683e6fd9df063ca3168e4b9a535f0f4ad94..a63d03e66e2b08ce50d4dc4a983c3a7b45d82f5f 100644 (file)
@@ -661,6 +661,11 @@ foptoas(int op, Type *t, int flg)
                return AFCOMDP;
        case FCASE(OCMP, TFLOAT64, Fpop2):
                return AFCOMDPP;
+       
+       case FCASE(OMINUS, TFLOAT32, 0):
+               return AFCHS;
+       case FCASE(OMINUS, TFLOAT64, 0):
+               return AFCHS;
        }
 
        fatal("foptoas %O %T %#x", op, t, flg);