History

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.

grischka committed 10 years ago

Commit 3b84e611 parent 85fca9e3 files · +0 −23Browse files

Unified · Split

3 files
  1. i386-gen.c +0 −10
  2. lib/libtcc1.c +0 −12
  3. tcctok.h +0 −1
i386-gen.c+0−10
@@ -1037,15 +1037,6 @@ ST_FUNC void gen_cvt_itof(int t) · 1036 unmodified lines
1037/* convert fp to int 't' type */1037/* convert fp to int 't' type */
1038ST_FUNC void gen_cvt_ftoi(int t)1038ST_FUNC void gen_cvt_ftoi(int t)
1039{1039{
1040#if 1
1041 gv(RC_FLOAT);
1042 save_reg(TREG_EAX);
1043 save_reg(TREG_EDX);
1044 gen_static_call(TOK___tcc_cvt_ftol);
1045 vtop->r = TREG_EAX; /* mark reg as used */
1046 if (t == VT_LLONG)
1047 vtop->r2 = TREG_EDX;
1048#else
1049 int bt = vtop->type.t & VT_BTYPE;1040 int bt = vtop->type.t & VT_BTYPE;
1050 if (bt == VT_FLOAT)1041 if (bt == VT_FLOAT)
1051 vpush_global_sym(&func_old_type, TOK___fixsfdi);1042 vpush_global_sym(&func_old_type, TOK___fixsfdi);
@@ -1058,7 +1049,6 @@ ST_FUNC void gen_cvt_ftoi(int t) · 6 unmodified lines
1058 vpushi(0);1049 vpushi(0);
1059 vtop->r = REG_IRET;1050 vtop->r = REG_IRET;
1060 vtop->r2 = REG_LRET;1051 vtop->r2 = REG_LRET;
1061#endif
1062}1052}
1063 1053
1064/* convert from one floating point type to another */1054/* convert from one floating point type to another */
lib/libtcc1.c+0−12
@@ -478,18 +478,6 @@ long long __ashldi3(long long a, int b) · 477 unmodified lines
478#endif478#endif
479}479}
480 480
481long long __tcc_cvt_ftol(long double x)
482{
483 unsigned c0, c1;
484 long long ret;
485 __asm__ __volatile__ ("fnstcw %0" : "=m" (c0));
486 c1 = c0 | 0x0C00;
487 __asm__ __volatile__ ("fldcw %0" : : "m" (c1));
488 __asm__ __volatile__ ("fistpll %0" : "=m" (ret));
489 __asm__ __volatile__ ("fldcw %0" : : "m" (c0));
490 return ret;
491}
492
493#endif /* !__x86_64__ */481#endif /* !__x86_64__ */
494 482
495/* XXX: fix tcc's code generator to do this instead */483/* XXX: fix tcc's code generator to do this instead */
tcctok.h+0−1
@@ -243,7 +243,6 @@ · 242 unmodified lines
243 DEF(TOK___fixsfdi, "__fixsfdi")243 DEF(TOK___fixsfdi, "__fixsfdi")
244 DEF(TOK___fixdfdi, "__fixdfdi")244 DEF(TOK___fixdfdi, "__fixdfdi")
245 DEF(TOK___fixxfdi, "__fixxfdi")245 DEF(TOK___fixxfdi, "__fixxfdi")
246 DEF(TOK___tcc_cvt_ftol, "__tcc_cvt_ftol")
247#endif246#endif
248 247
249#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64248#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64

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