Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The XOR linked list is perhaps the most prominent example of storing a reversible hash of two values and using a known value and the stored hash value to derive the other value. Is there a term for the general mechanism (or a way to describe it very concisely)?

As a related question, are there other somewhat recognized examples of using this mechanism?

In informally studying computer architecture, I have encountered what I think are two or three examples. One was a suggestion for a MRU-based cache way predictor by XORing the MRU bit with a bit derived from the address; the derived bit is the "known" value. The other was a similar, XORing the hysteresis bit of a branch predictor with a bit derived from branch information. A possible third example might be the agree branch predictor which uses a (possibly static) per-branch prediction to bias entries in a dynamic predictor so that aliasing tends to be non-destructive. A confirmation that these actually should be recognized as the same general mechanism as used by the XOR linked list would also be helpful.

share|cite|improve this question
I'd share it under the premature optimization anti-pattern. Memory nowadays is a lot cheaper than in the early days of computing when most of these tricks were invented. I know of two examples: the XOR swap (…) and maybe Complex numbers (as they can be represented by both two real parts and a magnitude+angle) – dtech Jan 30 '13 at 0:22
While memory capacity in PCs and servers is relatively vast, there is still interest in dense representations because of bandwidth and cache capacity. Computation vs. communication (and storage) tradeoffs increasingly favor computation. Also some embedded systems and some hardware data structures (like branch predictors) can be more capacity constrained. While XOR linked lists may now be almost entirely a historical footnote, the general mechanism may have significant albeit highly constrained application within the broad field of computing. – Paul A. Clayton Jan 30 '13 at 17:24
While true, I think that in most cases you mention general or special purpose compression does a better job. The only valid use case I can think of the very hardware-limited ones you mentioned. For bandwith and cache capacity I'd bet that a gzip'ed serialisation of a generic DLL (e.g.) is smaller than the uncompressed/gzipped serialisation of a XOR DLL. – dtech Jan 30 '13 at 19:02
“Is there a term for the general mechanism?” I think that it is called XOR. – Tsuyoshi Ito Jan 30 '13 at 19:07
@TsuyoshiIto I think this question can be reworded as "is there a generalization of the xor technique in xor linked lists". – Realz Slaw Nov 22 '13 at 16:18

It is a typical example of a space-time tradeoff trading increased time (CPU instructions required) for decreased space (memory required). There are many examples of this.

In this particular case I'd say it is a (simple) form of lossless compression. This because the data is stored in a minified but unusable form and needs some computation (decompression) done to receive the original (and usable) form, but no information is lost.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.