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
895 swapped = 0;895 swapped = 0;
896 if (swapped)896 if (swapped)
897 o(0xc9d9); /* fxch %st(1) */897 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 */
899 o(0xe0df); /* fnstsw %ax */902 o(0xe0df); /* fnstsw %ax */
900 if (op == TOK_EQ) {903 if (op == TOK_EQ) {
901 o(0x45e480); /* and $0x45, %ah */904 o(0x45e480); /* and $0x45, %ah */
x86_64-gen.c+9−3
@@ -1793,7 +1793,10 @@ void gen_opf(int op) · 1792 unmodified lines
1793 swapped = 0;1793 swapped = 0;
1794 if (swapped)1794 if (swapped)
1795 o(0xc9d9); /* fxch %st(1) */1795 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 */
1797 o(0xe0df); /* fnstsw %ax */1800 o(0xe0df); /* fnstsw %ax */
1798 if (op == TOK_EQ) {1801 if (op == TOK_EQ) {
1799 o(0x45e480); /* and $0x45, %ah */1802 o(0x45e480); /* and $0x45, %ah */
@@ -1877,8 +1880,11 @@ void gen_opf(int op) · 77 unmodified lines
1877 1880
1878 if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)1881 if ((vtop->type.t & VT_BTYPE) == VT_DOUBLE)
1879 o(0x66);1882 o(0x66);
1880 o(0x2e0f); /* ucomisd */1883 if (op == TOK_EQ || op == TOK_NE)
1881 1884 o(0x2e0f); /* ucomisd */
1885 else
1886 o(0x2f0f); /* comisd */
1887
1882 if (vtop->r & VT_LVAL) {1888 if (vtop->r & VT_LVAL) {
1883 gen_modrm(vtop[-1].r, r, vtop->sym, fc);1889 gen_modrm(vtop[-1].r, r, vtop->sym, fc);
1884 } else {1890 } 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