qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] target/ppc: Fix 64-bit decrementer


From: Richard Henderson
Subject: Re: [PATCH v2] target/ppc: Fix 64-bit decrementer
Date: Tue, 14 Sep 2021 06:21:39 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

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~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]