lkml.org 
[lkml]   [2003]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] 2.4.22pre10: {,un}likely_p() macros for pointers
Hi Albert,

On Sun, Aug 10, 2003 at 12:03:54AM -0400, Albert Cahalan wrote:
> I looked at the assembly (ppc, gcc 3.2.3) and didn't
> see any overhead.

same here on x86, gcc-2.95.3 and gcc-3.3.1. The compiler is smart enough not
to add several intermediate tests for !!(x).

> The !!x gives you a 0 or 1 while converting the type.
> So a (char*)0xfda9c80300000000ull will become a 1 of
> an acceptable type, allowing the macro to work as desired.

I agree (I didn't think about pointers, BTW). But what I meant is that we
don't need the result to be precisely 1, but we need it to be something the
compiler interpretes as different from zero, to match the condition. So it
should be cleaner to always check against 0 which is also OK for pointers,
whatever their type (according to Chip's link) :

likely => __builtin_expect(!(x), 0)
unlikely => __builtin_expect((x), 0)

Cheers,
Willy

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:47    [W:0.125 / U:2.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site