By: Linus Torvalds (torvalds.delete@this.linux-foundation.org), February 27, 2013 5:41 pm
Room: Moderated Discussions
Michael S (already5chosen.delete@this.yahoo.com) on February 27, 2013 4:24 pm wrote:
>
> Now, do we really need 4 flag bits in order to implement 12 (or even all 14) fundamental
> conditions? No, we don't
Oh, I'm sure you can encode it some odd way, since as you say, there are only 14 normal conditions you want to check, and half of them are the reverse ones. So pretty much by definition you could do some kind of "perfect hash" to map the actual conditions you get out of an ALU into just three bits.
But why would you? Especially since the four normal flag bits are literally what you get our of a two's-complement ALU with the simplest possible rules. So the re-encoding is still going to *compute* the four bits, it is then just going to hash them down to the particular combinations you wanted. It's not like the bits themselves disappeared, you just encoded them more densely by knowing which combinations people will test.
So I do claim that the 4 bits are pretty fundamental, the same way two's-complement is fundamental. Sure, you can encode numbers in base three too if you want to, but that doesn't make binary numbers any less fundamental - even if the "fundamental" nature of them ends up being at least partly about sanity of implementation.
Linus
>
> Now, do we really need 4 flag bits in order to implement 12 (or even all 14) fundamental
> conditions? No, we don't
Oh, I'm sure you can encode it some odd way, since as you say, there are only 14 normal conditions you want to check, and half of them are the reverse ones. So pretty much by definition you could do some kind of "perfect hash" to map the actual conditions you get out of an ALU into just three bits.
But why would you? Especially since the four normal flag bits are literally what you get our of a two's-complement ALU with the simplest possible rules. So the re-encoding is still going to *compute* the four bits, it is then just going to hash them down to the particular combinations you wanted. It's not like the bits themselves disappeared, you just encoded them more densely by knowing which combinations people will test.
So I do claim that the 4 bits are pretty fundamental, the same way two's-complement is fundamental. Sure, you can encode numbers in base three too if you want to, but that doesn't make binary numbers any less fundamental - even if the "fundamental" nature of them ends up being at least partly about sanity of implementation.
Linus