Community
cancel
Showing results for 
Search instead for 
Did you mean: 
songlinhai
Beginner
41 Views

question about hardware performance counter

Hi,

I am trying to use hardware performance counter to track which branch firefox is taking during execution. The event I am using is TAKEN sub-event in BR_INST_RETIRED. And the tool I am using is Linux perf.

In firefox, there is a piece of code like

if(flag){
..
}else{
..
}

After compiling, the related binary codes looks like:

cmp 0x0, flag
je <========================here


jmp




By loading a special web-page, only if branch is executed. But from the perf report, I find the "je " also causes BR_INST_RETIRED TAKEN event. I have add some fprintf into both if and else branch, and I am pretty sure that only if branch is executed.

So this problem is caused by "skid"? or some other reasons causing this problem? I can get which instruction causedBR_INST_RETIRED TAKEN from hardware performance counter, right?

Thanks a lot!

0 Kudos
2 Replies
jimdempseyatthecove
Black Belt
41 Views

Do you see any counts (e.g. INST_RETIRED) inside either/both sections of the if block?
If the entry into one of the sections is infrequent (e.g. once) you might not catch a count.

Jim Dempsey
songlinhai
Beginner
41 Views

Hi Jim,
I can seeINST_RETIRED in the if branch, and noINST_RETIRED in the else branch. This is reasonable, since only if branch is executed.
But in my experiment, I can see "je " instruction cause TAKEN BRAN_INST_RETIRED. Does this show that the else branch will be executed? Actually else branch is not executed.
Thanks a lot!
Linhai