From: Tim Deegan Subject: Re: [PATCH 4/4] bitmaps/bitops: Clarify tests for small constant size. Date: Fri, 29 Nov 2013 11:37:14 +0100 Message-ID: <20131129103714.GG51509@deinos.phlegethon.org> References: <1385656665-12551-1-git-send-email-tim@xen.org> <1385656665-12551-5-git-send-email-tim@xen.org> <52987584020000780010819D@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VmLRk-000301-Kr for xen-devel@lists.xenproject.org; Fri, 29 Nov 2013 10:37:16 +0000 Content-Disposition: inline In-Reply-To: <52987584020000780010819D@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel List-Id: xen-devel@lists.xenproject.org At 10:07 +0000 on 29 Nov (1385716068), Jan Beulich wrote: > >>> On 28.11.13 at 17:37, Tim Deegan wrote: > > No semantic changes, just makes the control flow a bit clearer. > > > > I was looking at this bcause the (-!__builtin_constant_p(x) | x__) > > formula is too clever for Coverity, but in fact it always takes me a > > minute or two to understand it too. :) > > I nevertheless like things like this... Yes, it's a nice trick, but I think we're better off with the readable code. > Anyway - did you check the > generated code is no worse with this change? Yep, the generated code is identical. > > -#define find_next_bit(addr, size, off) ({ \ > > - unsigned int r__ = (size); \ > > - unsigned int o__ = (off); \ > > - switch ( -!__builtin_constant_p(size) | r__ ) \ > > - { \ > > - case 0: (void)(addr); break; \ > > This dummy evaluation of addr ... Oops, yep. I'll fix for v2. Tim.