From 1ada32900b73e2b93b9420a19992a9512248d854 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Mon, 22 Jul 2019 02:31:08 +0200 Subject: [PATCH] riscv: Fix ftoi and ftof(long double->float) float to int must be truncations, not normal rounding. And ftof was typoed to select the wrong conversion function. This fixes tcctest.c completely. (make -C tests test1) --- riscv64-gen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/riscv64-gen.c b/riscv64-gen.c index 5e7ece7..ac40f00 100644 --- a/riscv64-gen.c +++ b/riscv64-gen.c @@ -1067,7 +1067,7 @@ ST_FUNC void gen_cvt_ftoi(int t) vtop++; vtop->r = dr; dr = ireg(dr); - EIu(0x53, 7, dr, rr, ((0x60 | (ft == VT_DOUBLE ? 1 : 0)) << 5) | (u ? 1 : 0) | (l ? 2 : 0)); // fcvt.[wl][u].[sd] + EIu(0x53, 1, dr, rr, ((0x60 | (ft == VT_DOUBLE ? 1 : 0)) << 5) | (u ? 1 : 0) | (l ? 2 : 0)); // fcvt.[wl][u].[sd] rtz } } @@ -1080,7 +1080,7 @@ ST_FUNC void gen_cvt_ftof(int dt) if (dt == VT_LDOUBLE || st == VT_LDOUBLE) { int func = (dt == VT_LDOUBLE) ? (st == VT_FLOAT ? TOK___extendsftf2 : TOK___extenddftf2) : - (st == VT_FLOAT ? TOK___trunctfsf2 : TOK___trunctfdf2); + (dt == VT_FLOAT ? TOK___trunctfsf2 : TOK___trunctfdf2); vpush_global_sym(&func_old_type, func); vrott(2); gfunc_call(1);