mirror of
git://repo.or.cz/tinycc.git
synced 2026-11-04 21:26:36 +08:00
x86_64: Fix long double to int cast
Some checks are pending
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86_64-win32 (push) Waiting to run
build and test / test-i386-win32 (push) Waiting to run
build and test / test-arm64-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
build and test / test-i386-linux (push) Waiting to run
Some checks are pending
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86_64-win32 (push) Waiting to run
build and test / test-i386-win32 (push) Waiting to run
build and test / test-arm64-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
build and test / test-i386-linux (push) Waiting to run
x86_64-gen.c:
- gen_cvt_ftoi()
Use TOK___fixxfdi for VT_LDOUBLE independently of the size of the
target integer type, avoiding a wrong conversion to doube.
This solves:
int main(void) {
long double x = 0.999999999999999999l;
return (int)x;
}
Before for VT_INT a long double was first converted to double with
rounding, possibly leading to a wrong result when truncating with
cvttsd2si.
This commit is contained in:
parent
e23dabed15
commit
32d1c0a561
@ -2121,18 +2121,15 @@ void gen_cvt_ftoi(int t)
|
|||||||
ft = vtop->type.t;
|
ft = vtop->type.t;
|
||||||
bt = ft & VT_BTYPE;
|
bt = ft & VT_BTYPE;
|
||||||
if (bt == VT_LDOUBLE) {
|
if (bt == VT_LDOUBLE) {
|
||||||
if (t != VT_INT) {
|
|
||||||
vpush_helper_func(TOK___fixxfdi);
|
vpush_helper_func(TOK___fixxfdi);
|
||||||
vswap();
|
vswap();
|
||||||
gfunc_call(1);
|
gfunc_call(1);
|
||||||
vpushi(0);
|
vpushi(0);
|
||||||
vtop->r = REG_IRET;
|
vtop->r = REG_IRET;
|
||||||
|
if (t != VT_INT)
|
||||||
vtop->r2 = REG_IRE2;
|
vtop->r2 = REG_IRE2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gen_cvt_ftof(VT_DOUBLE);
|
|
||||||
bt = VT_DOUBLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gv(RC_FLOAT);
|
gv(RC_FLOAT);
|
||||||
if (t != VT_INT)
|
if (t != VT_INT)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user