Re: Control flow hints
- From: "Doug Harrison [MVP]" <dsh@xxxxxxxx>
- Date: Fri, 23 Sep 2005 10:05:46 -0500
On Thu, 22 Sep 2005 11:48:01 +0200, "Piotr Wyderski"
<wyderskiREMOVE@xxxxxxxxxxxxxx> wrote:
>Hello,
>
>in GCC it is possible to give the compiler a hint about expected
>control flow probabilities using the "__builtin_expect" extension.
>One can define two macros:
>
> #define SELDOM(expr) __builtin_expect((expr),(1==0))
> #define OFTEN(expr) __builtin_expect((expr),(1==1))
>
>and use them like below:
>
> if (SELDOM(p == null)) {
>
> // this situation seldom happens, so the compiler can generate
> // this branch using worse translation method, i.e. prefer the
> // quality of the complementary control flow path
> }
>
> if (OFTEN(p != null)) {
>
> // The body of this branch should be generated as good as possible
> }
>
>This is very helpful when the probability of branch selection is known
>to the programmer. Is it possible to implement the same behaviour using
>VC++ extensions?
I'm not aware of anything like the above, but some other things that come
to mind include:
__declspec(noreturn)
__declspec(nothrow)
__assume
--
Doug Harrison
VC++ MVP
.
- Prev by Date: Re: std::vector's reserve(), erase() and clear()
- Next by Date: Re: Ping through the Windows SDK?
- Previous by thread: Re: Windows User Temp Directory
- Next by thread: VC++ 6 namespace bug?
- Index(es):
Relevant Pages
|