VAndrei
VAndrei

Reputation: 5570

Is branch predication used in gcc for ARM and how can we disable it?

I am compiling some binaries for an ARMv8 and ARMv7 devices and I want to disable the branch predication. I know this question has been asked once (here) but the target was an x86 machine. I'm using a linaro gcc for arm.

I'm doing this for experiment sake and I don't recommend this as a practice.

I have used perf to measure branch instructions / branch misses count.

So I have 2 questions:

  1. Is branch predication utilised gcc/g++ for arm?
  2. How can I disable it?

I have tried the following options:

So can I be sure that using -fno-if-conversion and -fno-guess-branch-probability are completely disabling branch predication?

Upvotes: 4

Views: 1087

Answers (1)

VAndrei
VAndrei

Reputation: 5570

After doing more research and tests I have my answer.

In ARMv7 ISA there are predicated instructions. The compiler uses them when it thinks they are beneficial. This can be disabled with -fno-if-conversion -fno-if-conversion2 compilation flags. In cases where the branch predictor does a good job, this can potentially increase performance.

ARMv8 AArch64 ISA has very limited support for branch predication so basically there-s not much to disable. The number of predicated instructions is reduced at minimum. Even when using the -fno-if-conversion flags I don-t see any impact on the number of executed instructions (used perf for this). This means that the branch predictor is even more important.

Upvotes: 1

Related Questions