1
0
mirror of https://github.com/golang/go synced 2024-11-20 08:44:39 -07:00

8g: float->uint64 conversion optimization

Using FUCOMIP instead of the FUCOMP-FSTSW-SAHF sequence gives better performance and saves code space.

R=rsc
CC=golang-dev
https://golang.org/cl/183139
This commit is contained in:
Evan Shaw 2010-01-06 19:28:19 -08:00 committed by Russ Cox
parent c713a1f982
commit a551ffe809

View File

@ -1350,15 +1350,11 @@ gmove(Node *f, Node *t)
// if 0 > v { answer = 0 } // if 0 > v { answer = 0 }
gmove(&zerof, &f0); gmove(&zerof, &f0);
gins(AFUCOMP, &f0, &f1); gins(AFUCOMIP, &f0, &f1);
gins(AFSTSW, N, &ax);
gins(ASAHF, N, N);
p1 = gbranch(optoas(OGT, types[tt]), T); p1 = gbranch(optoas(OGT, types[tt]), T);
// if 1<<64 <= v { answer = 0 too } // if 1<<64 <= v { answer = 0 too }
gmove(&two64f, &f0); gmove(&two64f, &f0);
gins(AFUCOMP, &f0, &f1); gins(AFUCOMIP, &f0, &f1);
gins(AFSTSW, N, &ax);
gins(ASAHF, N, N);
p2 = gbranch(optoas(OGT, types[tt]), T); p2 = gbranch(optoas(OGT, types[tt]), T);
patch(p1, pc); patch(p1, pc);
gins(AFMOVVP, &f0, t); // don't care about t, but will pop the stack gins(AFMOVVP, &f0, t); // don't care about t, but will pop the stack
@ -1382,9 +1378,7 @@ gmove(Node *f, Node *t)
// actual work // actual work
gmove(&two63f, &f0); gmove(&two63f, &f0);
gins(AFUCOMP, &f0, &f1); gins(AFUCOMIP, &f0, &f1);
gins(AFSTSW, N, &ax);
gins(ASAHF, N, N);
p2 = gbranch(optoas(OLE, types[tt]), T); p2 = gbranch(optoas(OLE, types[tt]), T);
gins(AFMOVVP, &f0, t); gins(AFMOVVP, &f0, t);
p3 = gbranch(AJMP, T); p3 = gbranch(AJMP, T);