By: rwessel (rrobertwessel.delete@this.yahoo.com), February 18, 2013 12:01 am
Room: Moderated Discussions
Wilco (Wilco.Dijkstra.delete@this.ntlworld.com) on February 17, 2013 1:47 pm wrote:
> Linus Torvalds (torvalds.delete@this.linux-foundation.org) on February 15, 2013 6:34 pm wrote:
> > Wilco (Wilco.Dijkstra.delete@this.ntlworld.com) on February 15, 2013 5:46 pm wrote:
> > >
> > > That's a good tradeoff, but you need 3 extra bits on compares of course
> >
> > It's worse than that. You'll want to do subtract-and-test,
> > bitops, yadda yadda. Compare really isn't even close
> > to complete. Otherwise you'll just end up playing games
> > with other arithmetic-logical ops to then be able to
> > compare the result. Which is *not* an improvement, no matter how some people would want to twist it,
>
> One condition bit for arithmetic and logical operations is enough, more than 90% of the time you only need a zero/non-zero
> result. You only need special opcodes for add with carry, but then again you need those anyway.
I have to disagree. A single condition code bit fails to fully take advantage of the separation of the computation of the condition, and its interpretation and use.
While comparing for equality (or a variation thereof) is certainly common, I don't think it's as common as you're saying. And with only a single CC bit, all of those will require specific instructions, or multiple instructions to compute the condition.
It's quite natural for a single comparison (or other) operation to be able to produce several results at once, especially as a tradeoff for a considerable multiplication of the number of versions of each CC setting instruction. SO if you're going to have CCs, having more that one bit is not much harder and has significant advantages.
S/360 takes a fairly workable intermediate approach. It has a two bit CC, which is set various ways by different instructions. Instructions using the CC as input (branch, conditional move, etc.), have a four bit mask to determine which of the four possible conditions are to be tested for. This does mean that S/360 has separate signed and unsigned integer add instructions (sum is zero, negative, positive or overflow, in the signed case, and the four combinations of carry and zero in the unsigned case).
OTOH, I think an intelligent selection of compare-and-branch instructions can eliminate a lot of CC usage and instruction pairs, and I think most ISAs have too many instructions which set the CCs (or not enough that don't).
> Linus Torvalds (torvalds.delete@this.linux-foundation.org) on February 15, 2013 6:34 pm wrote:
> > Wilco (Wilco.Dijkstra.delete@this.ntlworld.com) on February 15, 2013 5:46 pm wrote:
> > >
> > > That's a good tradeoff, but you need 3 extra bits on compares of course
> >
> > It's worse than that. You'll want to do subtract-and-test,
> > bitops, yadda yadda. Compare really isn't even close
> > to complete. Otherwise you'll just end up playing games
> > with other arithmetic-logical ops to then be able to
> > compare the result. Which is *not* an improvement, no matter how some people would want to twist it,
>
> One condition bit for arithmetic and logical operations is enough, more than 90% of the time you only need a zero/non-zero
> result. You only need special opcodes for add with carry, but then again you need those anyway.
I have to disagree. A single condition code bit fails to fully take advantage of the separation of the computation of the condition, and its interpretation and use.
While comparing for equality (or a variation thereof) is certainly common, I don't think it's as common as you're saying. And with only a single CC bit, all of those will require specific instructions, or multiple instructions to compute the condition.
It's quite natural for a single comparison (or other) operation to be able to produce several results at once, especially as a tradeoff for a considerable multiplication of the number of versions of each CC setting instruction. SO if you're going to have CCs, having more that one bit is not much harder and has significant advantages.
S/360 takes a fairly workable intermediate approach. It has a two bit CC, which is set various ways by different instructions. Instructions using the CC as input (branch, conditional move, etc.), have a four bit mask to determine which of the four possible conditions are to be tested for. This does mean that S/360 has separate signed and unsigned integer add instructions (sum is zero, negative, positive or overflow, in the signed case, and the four combinations of carry and zero in the unsigned case).
OTOH, I think an intelligent selection of compare-and-branch instructions can eliminate a lot of CC usage and instruction pairs, and I think most ISAs have too many instructions which set the CCs (or not enough that don't).