From e0e9a2a29562ac0f07c5d29070e1797fa48b144f Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Tue, 31 Dec 2013 23:40:21 +0800 Subject: Report error on NaN comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- i386-gen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'i386-gen.c') diff --git a/i386-gen.c b/i386-gen.c index b26b844..ebc0d14 100644 --- a/i386-gen.c +++ b/i386-gen.c @@ -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 */ -- cgit v1.3.1