On 12/16/2010 02:29 AM, Miles Bader wrote:
quoted text > Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> 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.
--
unsubscribe notice 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/
Messages in current thread:
Re: x86: A fast way to check capabilities of the current cpu , H. Peter Anvin , (Thu Dec 16, 8:38 am)