flat assembler
Message board for the users of flat assembler.

Index > Main > [x86]Predicting?

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 657
l4m2
Code:
pro1:
jmp [.table+eax*4]
.table:
dd pro1_0
dd pro1_1
dd pro1_2
dd pro1_3    

Code:
pro1:
test eax, eax
jz pro1_0
jmp [.table+(eax-1)*4]
.table:
dd pro1_1
dd pro1_2
dd pro1_3    

Will the second orogram run faster than the firat one when a majority of cases have eax equals to 0? If so, what rate makes the two runs nearly with the same average speed?
Post 01 Oct 2015, 11:21
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
l4m2
It won't, because all types of branches rely on the branch target buffer. The difference is how many entries in the BTB the branch can use. So in most cases the pipeline won't be flushed for any of the branches.

_________________
Faith is a superposition of knowledge and fallacy
Post 01 Oct 2015, 11:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17716
Location: In your JS exploiting you and your system
revolution
l4m2 wrote:
Will the second orogram run faster than the firat one when a majority of cases have eax equals to 0? If so, what rate makes the two runs nearly with the same average speed?
It depends upon your CPU and the conditions the program is run under.

Test it in your code and see if there is a difference. Then go with the fastest one. But this only works for your test system, other people may see different results.
Post 01 Oct 2015, 12:25
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 657
l4m2
o-o
Post 01 Oct 2015, 13:40
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.