On Friday, 5 February 2016 at 15:41:11 UTC, Fool wrote:
One swap usually decomposes into three moves.
Recently from reading some interesting hacks and super code, a
good swap can also be done via 3 xor operations (and avoiding an
intermediate storage unit).
http://aggregate.ee.engr.uky.edu/MAGIC/#Swap%20Values%20Without%20a%20Temporary
x ^= y;
y ^= x;
x ^= y;
Since these can be used directly as registers it might be faster
(assuming all 5 are mapped to registers until the final write
out, which might not work).