Showing results for 
Search instead for 
Did you mean: 

What is the signal raised when execution stage detects a misprediction?

BACLEAR signal is when the Decode stage sees a misprediction.

BTCLEAR signal is when the BTB sees a misprediction.

So what is the name of the signal for when the misprediction is detected in the execution unit and the whole pipeline is cleared?

0 Kudos
1 Reply

When the execution unit sees a branch miss-predict and the whole pipeline is cleared, the PerfMon event is called branch miss-predict (BR_MISS_PRED_RETIRED).  The branch miss-predict is counted when the offending instruction reaches retirement.  There is no way to count miss-predicts on instructions that are speculative.  That is, the execution unit might signal a problem about branch direction for a branch that never gets executed, as that branch might get cleared due to some other (earlier) branch or condition.

What happens at decode and earlier varies somewhat depending on which machine you are talking about, but the following is pretty much accurate on most Intel processors.  The BACLEAR occurs at decode time when the machine changes a decision about which fetch direction to take after a branch.  BACLEARs are not counted as branch miss-predicts.  In fact, the change in direction may or may not be to the final correct direction.  All that the BACLEAR is saying is that at decode time the machine cleared the part of the pipeline before the decode and selected a direction for fetching.  BACLEARs are indicated without regard for whether a branch will eventually retire.

The BTCLEAR is asserted much earlier in the pipeline.  On many machines it means you have a taken predicted branch.  (that is, a branch where you are making a prediction that the branch is taken).  BTCLEAR is not counted as a miss-predict.  But an instruction that has a BTCLEARs might also have a miss-predict later in the pipeline.