From 328aaa626fbbc3d664086b6dd4bde11bd71f9d5d Mon Sep 17 00:00:00 2001 From: Roger Chang Date: Tue, 13 Jun 2023 17:25:47 +0800 Subject: [PATCH] arch-riscv: Fix unexpected behavior of float operations in Mac OS The uint_fast16_t is the integer at least 16 bits size, it can be 32, 64 bits and more. Usually most of the simulations are in the x86-64 linux host, the size of uint_fast16_t is 64 bits. Therefore, there is no problem for double precision float operations and it can pass FloatMM test. However, in the Mac OS, the size of uint_fast16_t is 16 bits, it will lose the upper bits when converting float register bits to freg_t and it will generate unexpected results for FloatMM test. The change can guarantee that the size of data in freg_t is at least 64 bits and it will not lose any data from floating point to freg_t. Reference: https://developer.apple.com/documentation/kernel/uint_fast16_t https://codebrowser.dev/glibc/glibc/stdlib/stdint.h.html Change-Id: I3df6610f0903cdee0f56584d6cbdb51ac26c86c8 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/71519 Maintainer: Bobby Bruce Tested-by: kokoro Reviewed-by: Bobby Bruce --- src/arch/riscv/regs/float.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arch/riscv/regs/float.hh b/src/arch/riscv/regs/float.hh index 1654bdb627..4809372070 100644 --- a/src/arch/riscv/regs/float.hh +++ b/src/arch/riscv/regs/float.hh @@ -105,7 +105,7 @@ static constexpr float64_t f64(freg_t r) { return r; } static constexpr freg_t freg(float16_t f) { return {boxF16(f.v)}; } static constexpr freg_t freg(float32_t f) { return {boxF32(f.v)}; } static constexpr freg_t freg(float64_t f) { return f; } -static constexpr freg_t freg(uint_fast16_t f) { return {f}; } +static constexpr freg_t freg(uint_fast64_t f) { return {f}; } namespace float_reg {