Report error on NaN comparison
Use comisd / fcompp for float comparison (except TOK_EQ and TOK_NE) instead of ucomisd / fucompp to detect NaN comparison. Thanks Vincent Lefèvre for the bug report and for also giving the solution.
This commit is contained in:
parent
59b8007f98
commit
e0e9a2a295
2 changed files with 13 additions and 4 deletions
|
@ -895,7 +895,10 @@ ST_FUNC void gen_opf(int op)
|
||||||
swapped = 0;
|
swapped = 0;
|
||||||
if (swapped)
|
if (swapped)
|
||||||
o(0xc9d9); /* fxch %st(1) */
|
o(0xc9d9); /* fxch %st(1) */
|
||||||
o(0xe9da); /* fucompp */
|
if (op == TOK_EQ || op == TOK_NE)
|
||||||
|
o(0xe9da); /* fucompp */
|
||||||
|
else
|
||||||
|
o(0xd9de); /* fcompp */
|
||||||
o(0xe0df); /* fnstsw %ax */
|
o(0xe0df); /* fnstsw %ax */
|
||||||
if (op == TOK_EQ) {
|
if (op == TOK_EQ) {
|
||||||
o(0x45e480); /* and $0x45, %ah */
|
o(0x45e480); /* and $0x45, %ah */
|
||||||
|
|
10
x86_64-gen.c
10
x86_64-gen.c
|
@ -1793,7 +1793,10 @@ void gen_opf(int op)
|
||||||
swapped = 0;
|
swapped = 0;
|
||||||
if (swapped)
|
if (swapped)
|
||||||
o(0xc9d9); /* fxch %st(1) */
|
o(0xc9d9); /* fxch %st(1) */
|
||||||
o(0xe9da); /* fucompp */
|
if (op == TOK_EQ || op == TOK_NE)
|
||||||
|
o(0xe9da); /* fucompp */
|
||||||
|
else
|
||||||
|
o(0xd9de); /* fcompp */
|
||||||
o(0xe0df); /* fnstsw %ax */
|
o(0xe0df); /* fnstsw %ax */
|
||||||
if (op == TOK_EQ) {
|
if (op == TOK_EQ) {
|
||||||
o(0x45e480); /* and $0x45, %ah */
|
o(0x45e480); /* and $0x45, %ah */
|
||||||
|
@ -1877,7 +1880,10 @@ void gen_opf(int op)
|
||||||
|
|
||||||
if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
|
if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
|
||||||
o(0x66);
|
o(0x66);
|
||||||
o(0x2e0f); /* ucomisd */
|
if (op == TOK_EQ || op == TOK_NE)
|
||||||
|
o(0x2e0f); /* ucomisd */
|
||||||
|
else
|
||||||
|
o(0x2f0f); /* comisd */
|
||||||
|
|
||||||
if (vtop->r & VT_LVAL) {
|
if (vtop->r & VT_LVAL) {
|
||||||
gen_modrm(vtop[-1].r, r, vtop->sym, fc);
|
gen_modrm(vtop[-1].r, r, vtop->sym, fc);
|
||||||
|
|
Loading…
Reference in a new issue