question about hardware performance counter

question about hardware performance counter


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






After compiling, the related binary codes looks like:

cmp 0x0, flag

je <========================here


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!

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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

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

Leave a Comment

Please sign in to add a comment. Not a member? Join today