Do switch statements in C make an empty x86 pipeline?

Does the switch statement in C (assuming it uses a jump table) deallocate the x86 processor pipeline? I think this may be due to the fact that as a result of the table search, you will need to find out which command to execute next. Can he send this result back early enough so that the pipeline is not completely empty?

+4
source share
2 answers

I found the microarchitecture of Intel, AMD and VIA processors will be a good source for issues like yours.

+6
source

The transition table does not necessarily empty the pipeline. Indirect branches are predicted on modern processors, and industry predictors do a better job than you might expect. Obviously, a correctly predicted indirect branch does not cause a breakdown.

Non-branching is generally preferable, but often impossible (or introduces so much overhead to be a net loss). Replacing jump tables using a sequence of conditional branches is sometimes useful, but only if the number of branches in the replacement sequence is sufficiently small.

+7
source

All Articles