By: Wilco (Wilco.Dijkstra.delete@this.ntlworld.com), February 25, 2013 7:36 am
Room: Moderated Discussions
EduardoS (no.delete@this.spam.com) on February 25, 2013 6:24 am wrote:
> Wilco (Wilco.Dijkstra.delete@this.ntlworld.com) on February 25, 2013 5:54 am wrote:
> > If you want to show how useful 4 condition bits are compared to having 1, what you need to measure is the
> > distribution of conditional branches after ALU instructions. Obviously that excludes compares which are
> > unchanged by how many condition bits are used. That's what I did, and that gives you 96% equality.
>
> By equality you means, the zero flag? When the result of the operation is 0? Ok, it is usefull
> for XOR, SUB, AND, OR, SHL, but what about ADD? How is this any usefull for ADD?
Well it is useful for add in the same way it is useful for any other operation. Programmers just tend to compare with zero a lot.
Note if you really believe in condition codes, even loads should set the Z flag since ldr; cmp #0; beq/bne is extremely common (of course I prefer Thumb-2 cbz/cbnz instead).
> Also, ADD and SUB sometimes needs to check for overflow or carry, how about that?
For those you'd need additional instructions, just like add with carry.
> For floating point, checking for zero, overflow, NaN, what else?
For floating point you always use a compare first.
> Maybe GCC doesn't use it, Linux kernel is unlikely to use as well, but then there are
> applications and markets for wich such things are important, like, a database wich
> checks every operation for overflow, don't you think you are doing the wrong think
> by just looking at what GCC does and assuming that's the case for everybody else?
Sure just looking at GCC is not enough if you do serious ISA research. However it is fairly representative, so more than sufficient for discussions like this. Note the larger an application is, the more likely it will end up being "close to average".
As long as you stay with C/C++ then you would not see overflow checks even if they were used in the source. For Java/C# things are different of course, but even then the number of overflow checks is small compared to the number of additions.
Wilco
> Wilco (Wilco.Dijkstra.delete@this.ntlworld.com) on February 25, 2013 5:54 am wrote:
> > If you want to show how useful 4 condition bits are compared to having 1, what you need to measure is the
> > distribution of conditional branches after ALU instructions. Obviously that excludes compares which are
> > unchanged by how many condition bits are used. That's what I did, and that gives you 96% equality.
>
> By equality you means, the zero flag? When the result of the operation is 0? Ok, it is usefull
> for XOR, SUB, AND, OR, SHL, but what about ADD? How is this any usefull for ADD?
Well it is useful for add in the same way it is useful for any other operation. Programmers just tend to compare with zero a lot.
Note if you really believe in condition codes, even loads should set the Z flag since ldr; cmp #0; beq/bne is extremely common (of course I prefer Thumb-2 cbz/cbnz instead).
> Also, ADD and SUB sometimes needs to check for overflow or carry, how about that?
For those you'd need additional instructions, just like add with carry.
> For floating point, checking for zero, overflow, NaN, what else?
For floating point you always use a compare first.
> Maybe GCC doesn't use it, Linux kernel is unlikely to use as well, but then there are
> applications and markets for wich such things are important, like, a database wich
> checks every operation for overflow, don't you think you are doing the wrong think
> by just looking at what GCC does and assuming that's the case for everybody else?
Sure just looking at GCC is not enough if you do serious ISA research. However it is fairly representative, so more than sufficient for discussions like this. Note the larger an application is, the more likely it will end up being "close to average".
As long as you stay with C/C++ then you would not see overflow checks even if they were used in the source. For Java/C# things are different of course, but even then the number of overflow checks is small compared to the number of additions.
Wilco