History

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.

Thomas Preud'homme committed 12 years ago

Commit e0e9a2a1 parent 59b80072 files · +13 −4Browse files

Unified · Split

2 files
  1. i386-gen.c +4 −1
  2. x86_64-gen.c +9 −3
i386-gen.c+4−1
@@ -895,7 +895,10 @@ ST_FUNC void gen_opf(int op) · 894 unmodified lines
895895 swapped = 0;
896896 if (swapped)
897897 o(0xc9d9); /* fxch %st(1) */
898− o(0xe9da); /* fucompp */
898+ if (op == TOK_EQ || op == TOK_NE)
899+ o(0xe9da); /* fucompp */
900+ else
901+ o(0xd9de); /* fcompp */
899902 o(0xe0df); /* fnstsw %ax */
900903 if (op == TOK_EQ) {
901904 o(0x45e480); /* and $0x45, %ah */
x86_64-gen.c+9−3
@@ -1793,7 +1793,10 @@ void gen_opf(int op) · 1792 unmodified lines
17931793 swapped = 0;
17941794 if (swapped)
17951795 o(0xc9d9); /* fxch %st(1) */
1796− o(0xe9da); /* fucompp */
1796+ if (op == TOK_EQ || op == TOK_NE)
1797+ o(0xe9da); /* fucompp */
1798+ else
1799+ o(0xd9de); /* fcompp */
17971800 o(0xe0df); /* fnstsw %ax */
17981801 if (op == TOK_EQ) {
17991802 o(0x45e480); /* and $0x45, %ah */
@@ -1877,8 +1880,11 @@ void gen_opf(int op) · 77 unmodified lines
18771880
18781881 if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
18791882 o(0x66);
1880− o(0x2e0f); /* ucomisd */
1881−
1883+ if (op == TOK_EQ || op == TOK_NE)
1884+ o(0x2e0f); /* ucomisd */
1885+ else
1886+ o(0x2f0f); /* comisd */
1887+
18821888 if (vtop->r & VT_LVAL) {
18831889 gen_modrm(vtop[-1].r, r, vtop->sym, fc);
18841890 } else {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t