Comment by xxpor
1 year ago
+1 on reading.
I hardly consider myself an expert ARM ASM programmer (or even an amateur...), but a baseline level of how to read it even if you have to look up a bunch of instructions every time can be super useful for performance work, especially if you have the abstract computer engineering know how to back it up.
For example, it turns out that gcc 7.3 (for arm64) doesn't optimize
foo() ? bar() : baz();
the same as
if (foo()) {
bar();
} else {
baz();
}
!
The former was compiled into a branchless set of instructions, while the latter had a branch!
You can use __builtin_expect_with_probability with 0.5 to tell the compiler to be consistent in using a select rather than a branch.