From 3b84e61eaddb068707a7a3d40a9ebd5e69975965 Mon Sep 17 00:00:00 2001 From: grischka Date: Fri, 14 Oct 2016 11:23:48 +0200 Subject: [PATCH] Revert "partial revert of the commit 4ad186c5ef61" There seems nothing wrong. With int t1 = 176401255; float f = 0.25; int t2 = t1 * f; // 176401255 * 0.25 = 44100313.75 according to the arithmetic conversion rules, the number 176401255 needs to be converted to float, and the compiler can choose either the nearest higher or nearest lower representable number "in an implementation-defined manner". Which may be 176401248 or 176401264. So as result both 44100312 and 44100313 are correct. This reverts commit 664c19ad5ef16f3463087a33ecfe5d5ac24f81ec. --- i386-gen.c | 10 ---------- lib/libtcc1.c | 12 ------------ tcctok.h | 1 - 3 files changed, 23 deletions(-) diff --git a/i386-gen.c b/i386-gen.c index 946e42d3..7d9c3d00 100644 --- a/i386-gen.c +++ b/i386-gen.c @@ -1037,15 +1037,6 @@ ST_FUNC void gen_cvt_itof(int t) /* convert fp to int 't' type */ ST_FUNC void gen_cvt_ftoi(int t) { -#if 1 - gv(RC_FLOAT); - save_reg(TREG_EAX); - save_reg(TREG_EDX); - gen_static_call(TOK___tcc_cvt_ftol); - vtop->r = TREG_EAX; /* mark reg as used */ - if (t == VT_LLONG) - vtop->r2 = TREG_EDX; -#else int bt = vtop->type.t & VT_BTYPE; if (bt == VT_FLOAT) vpush_global_sym(&func_old_type, TOK___fixsfdi); @@ -1058,7 +1049,6 @@ ST_FUNC void gen_cvt_ftoi(int t) vpushi(0); vtop->r = REG_IRET; vtop->r2 = REG_LRET; -#endif } /* convert from one floating point type to another */ diff --git a/lib/libtcc1.c b/lib/libtcc1.c index c3ff7fe0..0edfbd86 100644 --- a/lib/libtcc1.c +++ b/lib/libtcc1.c @@ -478,18 +478,6 @@ long long __ashldi3(long long a, int b) #endif } -long long __tcc_cvt_ftol(long double x) -{ - unsigned c0, c1; - long long ret; - __asm__ __volatile__ ("fnstcw %0" : "=m" (c0)); - c1 = c0 | 0x0C00; - __asm__ __volatile__ ("fldcw %0" : : "m" (c1)); - __asm__ __volatile__ ("fistpll %0" : "=m" (ret)); - __asm__ __volatile__ ("fldcw %0" : : "m" (c0)); - return ret; -} - #endif /* !__x86_64__ */ /* XXX: fix tcc's code generator to do this instead */ diff --git a/tcctok.h b/tcctok.h index 775b338e..270c1edf 100644 --- a/tcctok.h +++ b/tcctok.h @@ -243,7 +243,6 @@ DEF(TOK___fixsfdi, "__fixsfdi") DEF(TOK___fixdfdi, "__fixdfdi") DEF(TOK___fixxfdi, "__fixxfdi") - DEF(TOK___tcc_cvt_ftol, "__tcc_cvt_ftol") #endif #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64