From: Frank Chang <frank.ch...@sifive.com> If a 16-bit input is not properly nanboxed, then the input is replaced with the default qnan.
Signed-off-by: Frank Chang <frank.ch...@sifive.com> --- target/riscv/translate.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 24026f901d1..95921296a56 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -110,6 +110,16 @@ static void gen_nanbox_s(TCGv_i64 out, TCGv_i64 in) * * Here, the result is always nan-boxed, even the canonical nan. */ +static void gen_check_nanbox_h(TCGv_i64 out, TCGv_i64 in) +{ + TCGv_i64 t_max = tcg_const_i64(0xffffffffffff0000ull); + TCGv_i64 t_nan = tcg_const_i64(0xffffffffffff7e00ull); + + tcg_gen_movcond_i64(TCG_COND_GEU, out, in, t_max, in, t_nan); + tcg_temp_free_i64(t_max); + tcg_temp_free_i64(t_nan); +} + static void gen_check_nanbox_s(TCGv_i64 out, TCGv_i64 in) { TCGv_i64 t_max = tcg_const_i64(0xffffffff00000000ull); -- 2.17.1