What is the purpose of the Parity Flag on a CPU?

后端 未结 3 1507
无人及你
无人及你 2021-02-05 04:27

Some CPUs (notably x86 CPUs) feature a parity flag on their status register. This flag indicates whether the number of bits of the result of an operation is odd or even.

3条回答
  •  迷失自我
    2021-02-05 04:53

    There's one practical micro-optimization achievable with parity -- that's bit swapping as used eg in fourier transform address generation using the butterfly kernel.

    To swap bits 7 and 0, one can exploit parity of (a&0x81) followed by conditional (a^=0x81). Repeat for bits 6/1, 5/2 and 4/3.

提交回复
热议问题