Richard Sandiford <richard.sandif...@arm.com> writes: > Karl Meakin <karl.mea...@arm.com> writes: >> +// If the branch destination is out of range (1KiB), we have to generate an >> +// extra B instruction (which can handle larger displacements) and branch >> around >> +// it >> +int far_branch(i32 x, i32 y) { >> + volatile int z = 0; >> + if (x == y) { > > It might be worth making this: > > if (__builtin_expect (x == y, 0)) {
Gah, I meant: if (__builtin_expect (x == y, 1)) { sorry! The branch should be assumed untaken, and so the condition should be assumed true. > as a way of ensuring that nothing tries to "optimise" the code by > inverting the branch (and avoiding the far branch).