Quoted from https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html:
-falign-labels
-falign-labels=n
Align all branch targets to a power-of-two boundary, skipping up to n bytes like -falign-functions. This option can easily make code slower, because it must insert dummy operations for when the branch target is reached in the usual flow of the code.
-fno-align-labels and -falign-labels=1 are equivalent and mean that labels are not aligned.
If -falign-loops or -falign-jumps are applicable and are greater than this value, then their values are used instead.
If n is not specified or is zero, use a machine-dependent default which is very likely to be ‘1’, meaning no alignment.
Enabled at levels -O2, -O3.
Thinking about this flag more makes it lose even more sense... there are consequences of provoking code cache miss, and what even enabling means when parameter takes numeric value (1..)?
It doesn't say that. It says that can easily make code slower. It means, that in certain situations, it can make code slower. In other situations, it can make code faster.
Alignment causes to run code slower:
nop
operations slow down codeAlignment could cause to run code faster: branch prediction, instruction fetch, and god-knows-what.
In the case of a single if
, it is hard to say which effect is stronger. It depends on the conditions.
However, for a loop, usually code becomes faster. Why? Because slow factors happen only once, but every cycle of the loop will be executed faster.
(My GCC seems to align labels to 8)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With