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:
Thomas Preud'homme 2013-12-31 23:40:21 +08:00
parent 59b8007f98
commit e0e9a2a295
2 changed files with 13 additions and 4 deletions

View File

@ -895,7 +895,10 @@ ST_FUNC void gen_opf(int op)
swapped = 0;
if (swapped)
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 */
if (op == TOK_EQ) {
o(0x45e480); /* and $0x45, %ah */

View File

@ -1793,7 +1793,10 @@ void gen_opf(int op)
swapped = 0;
if (swapped)
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 */
if (op == TOK_EQ) {
o(0x45e480); /* and $0x45, %ah */
@ -1877,8 +1880,11 @@ void gen_opf(int op)
if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
o(0x66);
o(0x2e0f); /* ucomisd */
if (op == TOK_EQ || op == TOK_NE)
o(0x2e0f); /* ucomisd */
else
o(0x2f0f); /* comisd */
if (vtop->r & VT_LVAL) {
gen_modrm(vtop[-1].r, r, vtop->sym, fc);
} else {