This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Question on branch prediction and conditional select instructions

Hi,

I have a question on branch prediction and conditional select instructions.

In this document (https://developer.arm.com/architectures/learn-the-architecture/armv8-a-instruction-set-architecture/program-flow-conditional-select-instructions), it mentions the following.

Importantly, conditional selects also remove the need to branch. In modern processors, this kind of branch can be difficult for the branch prediction logic to predict correctly. A mispredicted branch can have a negative effect on performance, it is better that you remove branches where possible.

It sounds like there will not be prediction computation squashing when conditional select instructions are used. But can it be true? For example, when this set of instructions is given,

CMP X0, XZR

CSEL X1, X2, X3, EQ

< rest of calculation is based on X1 >

If X0 is zero, then X1 is X2. if X0 is non-zero, then X1 is X3.

From my understanding, any branch prediction work based on X1 = X2 has to be squashed if X1 becomes X3 and vise-versa.

Or am I missing something?

Thanks,

Andrew

Parents Reply Children