Reasons For Use in Practice
In most practical scenarios, the trivial swap algorithm using a temporary register is more efficient. Limited situations in which XOR swapping may be practical include:
- On a processor where the instruction set encoding permits the XOR swap to be encoded in a smaller number of bytes;
- In a region with high register pressure, it may allow the register allocator to avoid spilling a register.
- In microcontrollers where available RAM is very limited.
Because these situations are rare, most optimizing compilers do not generate XOR swap code.
Read more about this topic: XOR Swap Algorithm
Famous quotes containing the words reasons for, reasons and/or practice:
“Metaphysics is the finding of bad reasons for what we believe upon instinct; but to find these reasons is no less an instinct.”
—F.H. (Francis Herbert)
“... to a poet, the human community is like the community of birds to a bird, singing to each other. Love is one of the reasons we are singing to one another, love of language itself, love of sound, love of singing itself, and love of the other birds.”
—Sharon Olds (b. 1942)
“Indubitably, Magick is one of the subtlest and most difficult of the sciences and arts. There is more opportunity for errors of comprehension, judgement and practice than in any other branch of physics.”
—Aleister Crowley (18751947)