From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZRjXO-00083E-Of for qemu-devel@nongnu.org; Tue, 18 Aug 2015 12:14:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZRjXL-00071b-H2 for qemu-devel@nongnu.org; Tue, 18 Aug 2015 12:14:58 -0400 Received: from mail-qk0-x22b.google.com ([2607:f8b0:400d:c09::22b]:33753) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZRjXL-00071V-D0 for qemu-devel@nongnu.org; Tue, 18 Aug 2015 12:14:55 -0400 Received: by qkfj126 with SMTP id j126so59972183qkf.0 for ; Tue, 18 Aug 2015 09:14:54 -0700 (PDT) Received: from anchor.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by smtp.googlemail.com with ESMTPSA id m62sm10319947qhb.45.2015.08.18.09.14.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2015 09:14:53 -0700 (PDT) Sender: Richard Henderson References: <1439849015-11127-1-git-send-email-rth@twiddle.net> <1439849015-11127-3-git-send-email-rth@twiddle.net> From: Richard Henderson Message-ID: <55D359FB.2070709@twiddle.net> Date: Tue, 18 Aug 2015 09:14:51 -0700 MIME-Version: 1.0 In-Reply-To: <1439849015-11127-3-git-send-email-rth@twiddle.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] target-alpha: Special case cmpbge with zero List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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~