On 9/14/21 2:47 AM, Cédric Le Goater wrote:
On 9/14/21 11:19 AM, Peter Maydell wrote:/* Truncate value to decr_width and sign extend for simplicity */ - value &= ((1ULL << nr_bits) - 1); + value = sextract64(value, 0, nr_bits); negative = !!(value & (1ULL << (nr_bits - 1))); if (negative) { value |= (0xFFFFFFFFULL << nr_bits);I think these lines that say "if negative then force all the high bits to one" are also no longer required. That is, this entire section of code: value &= ((1ULL << nr_bits) - 1); negative = !!(value & (1ULL << (nr_bits - 1))); if (negative) { value |= (0xFFFFFFFFULL << nr_bits); } is an open-coded sign-extension, which can all be replaced with the single line value = sextract64(value, 0, nr_bits);'negative' is used for more tests afterwards but you are right. I will respin with more changes.
After the sign-extension, negative needs no complicated expression. value = sextract64(value, 0, nr_bits); negative = (target_long)value < 0; r~
