[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] target-alpha: Special case cmpbge with zero
From: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] target-alpha: Special case cmpbge with zero |
Date: |
Tue, 18 Aug 2015 09:14:51 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 |
On 08/17/2015 03:03 PM, Richard Henderson wrote:
> + uint64_t c = (a - 0x0101010101010101ULL) & ~a & 0x8080808080808080ULL;
Ho hum. I was mislead. This formulation is good for noticing *some* zero in a
word, but not which particular bytes contain zeros. This difference is hard to
spot in how alpha tends to use this instruction, but this did lead to
bizzare filesystem behaviour.
Failure occurs when a zero preceeds a byte with a one, e.g.
000000010022656d
0100016462687773
Avoiding the problem requires one extra operation. E.g.
uint64_t m = 0x7f7f7f7f7f7f7f7fULL;
uint64_t c = ~(((a & m) + m) | a | m);
Which equates to (1) clear high bit (2) carry non-zero into high bit (3)
remerge high bit from source, (4) set low bits and invert to make high bit
positive for found zero.
r~