3 ms·
That would just load each global variable into registers and write them back to memory, swapping them. If the compiler had decided to put two locals located al
by Ferrotin 4y ago
That would just load each global variable into registers and write them back to memory, swapping them.
If the compiler had decided to put two locals located already in registers, and had the swap in a branch, like so:
if (foo()) {
bar();
(a, b) = (b, a);
}
Then the registers might get swapped with an xchg instruction or something, I don’t know. The compiler’s goal is to have pipelined execution be as fast as possible, so there’s no way it’s going to use bit-mangling operations that would get in the way of that.