Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756534Ab0LPPjc (ORCPT ); Thu, 16 Dec 2010 10:39:32 -0500 Received: from terminus.zytor.com ([198.137.202.10]:42578 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754877Ab0LPPjb (ORCPT ); Thu, 16 Dec 2010 10:39:31 -0500 Message-ID: <4D0A3267.40300@zytor.com> Date: Thu, 16 Dec 2010 07:38:15 -0800 From: "H. Peter Anvin" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Thunderbird/3.1.6 MIME-Version: 1.0 To: Miles Bader CC: Miguel Ojeda , Andrew Morton , Christoph Lameter , Tejun Heo , Pekka Enbeerg , linux-kernel@vger.kernel.org, Eric Dumazet , Mathieu Desnoyers Subject: Re: x86: A fast way to check capabilities of the current cpu References: <20101215125626.25f7d648.akpm@linux-foundation.org> <4D092D15.7030700@zytor.com> <4D093580.9000303@zytor.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1223 Lines: 32 On 12/16/2010 02:29 AM, Miles Bader wrote: > Miguel Ojeda writes: >>>> If they aren't, and are stored in a variable for whatever reason, then >>>> the || form will generate additional instructions to booleanize the >>>> value for no good reason. >> >> I think hpa was talking about some code where gcc can not optimize out >> the assignment (e.g. volatile, complex code, using the int outside >> conditional expressions, etc.). > > Sure, but that seems to assume that the alternatives are otherwise > equivalent in the common case, when used in a boolean context. > > If that's not true then one risks pessimizing the common case to make an > uncommon case more efficient. > The alternatives are equivalent when used in the common context. Your examples are bogus, because they don't account for the __builtin_constant_p(). -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/