From e42230fca8075461a638c81250e1ff5ab9dcf5fa Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 15 Mar 2023 03:59:23 -0700 Subject: [PATCH] fix limit and move comment --- openpower/sv/int_fp_mv.mdwn | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/openpower/sv/int_fp_mv.mdwn b/openpower/sv/int_fp_mv.mdwn index a1c0981ee..ff64e6654 100644 --- a/openpower/sv/int_fp_mv.mdwn +++ b/openpower/sv/int_fp_mv.mdwn @@ -636,17 +636,18 @@ switch(CVM) result <- si64_CONVERT_FROM_BFP(range_max) default: # JavaScript semantics # CVM = 6, 7 are illegal instructions - limit <- bfp_CONVERT_FROM_UI64(0xFFFF_FFFF_FFFF_FFFF) + + # this works because the largest type we try to + # convert from has 53 significand bits, and the + # largest type we try to convert to has 64 bits, + # and the sum of those is strictly less than the + # 128 bits of the intermediate result. + limit <- bfp_CONVERT_FROM_UI128([1] * 128) if IsInf(rnd) or IsNaN(rnd) then result <- [0] * 64 else if bfp_COMPARE_GT(bfp_ABSOLUTE(rnd), limit) then result <- [0] * 64 else - # this works because the largest type we try to - # convert from has 53 significand bits, and the - # largest type we try to convert to has 64 bits, - # and the sum of those is strictly less than the - # 128 bits of the intermediate result. result128 <- si128_CONVERT_FROM_BFP(rnd) result <- result128[64:127] & js_mask -- 2.30.2