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:
“Happy the man who has been able to know the reasons for things.”
—Virgil [Publius Vergilius Maro] (7019 B.C.)
“I call it our collective inheritance of isolation. We inherit isolation in the bones of our lives. It is passed on to us as sure as the shape of our noses and the length of our legs. When we are young, we are taught to keep to ourselves for reasons we may not yet understand. As we grow up we become the men who never cry and the women who never complain. We become another generation of people expected not to bother others with our problems.”
—Paula C. Lowe (20th century)
“The classroom, with all its limitations, remains a location of possibility. In that field of possibility we have the opportunity to labor for freedom, to demand of ourselves and our comrades, an openness of mind and heart that allows us to face reality even as we collectively imagine ways to move beyond boundaries, to transgress. This is education as the practice of freedom.”
—bell hooks (b. c. 1955)