dotgnu-libjit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Dotgnu-libjit] performance of conditionals


From: Kirill Kononenko
Subject: Re: [Dotgnu-libjit] performance of conditionals
Date: Wed, 12 Nov 2008 18:24:21 +0300

Hello


There are two things to consider:

1. You should assume that a conditional branch is taken in 90% of cases.
2. And a simplied CPU will predict the same branch target, which was
taken the previous time.


Thanks,
Kirill


2008/11/10 Paul Brannan <address@hidden>:
> I have a conditional in which one case is many more times likely to
> occur than the other case.  Currently the implementation does this:
>
>      branch_if_not(cond, L1)
>      <true case>
>      branch(L2)
>  L1: <false case>
>  L2: <remainder of code>
>      ...
>      return
>
> I have considered implementing it like this instead:
>
>      branch_if_not(cond, L1)
>      <true case>
>  L2: <remainder of code>
>      ...
>      return
>  L1: <false case>
>      branch(L2)
>
> thus avoiding the branch for the usual case.
>
> I'm not a low-level guru, so I'm curious how in general this sort of
> refactoring affects performance.
>
> I would write a benchmark, but I'm not sure how to write it in such a
> way that it would necessarily reflect real-world performance.
>
> Thoughts?
>
> Paul
>
>
>
> _______________________________________________
> Dotgnu-libjit mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/dotgnu-libjit
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]