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
10371037 /* convert fp to int 't' type */
10381038 ST_FUNC void gen_cvt_ftoi(int t)
10391039 {
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
10491040 int bt = vtop->type.t & VT_BTYPE;
10501041 if (bt == VT_FLOAT)
10511042 vpush_global_sym(&func_old_type, TOK___fixsfdi);
@@ -1058,7 +1049,6 @@ ST_FUNC void gen_cvt_ftoi(int t) · 6 unmodified lines
10581049 vpushi(0);
10591050 vtop->r = REG_IRET;
10601051 vtop->r2 = REG_LRET;
1061−#endif
10621052 }
10631053
10641054 /* 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
478478 #endif
479479 }
480480
481−long 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−
493481 #endif /* !__x86_64__ */
494482
495483 /* XXX: fix tcc's code generator to do this instead */
tcctok.h+0−1
@@ -243,7 +243,6 @@ · 242 unmodified lines
243243 DEF(TOK___fixsfdi, "__fixsfdi")
244244 DEF(TOK___fixdfdi, "__fixdfdi")
245245 DEF(TOK___fixxfdi, "__fixxfdi")
246− DEF(TOK___tcc_cvt_ftol, "__tcc_cvt_ftol")
247246 #endif
248247
249248 #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