By: Jouni Osmala (josmala.delete@this.cc.hut.fi), February 17, 2013 1:10 pm
Room: Moderated Discussions
> Isn't it true that the following code could run faster with 2 CC registers:
>
>
No since that && in if statement is short circuit statement.
if((a!=null)&&(*a==b))
With any compiler trying to do that with 2 CC registers, would
remove an effect of null check that language definition states would work.
However
if((a==b)&(c==d)) is probably what you meant but its not a common way of writing that statement.
And for that to work the way you want you would need logical operations to flags registers.
That means extra read ports there and special unit to handle it.
I like the alpha way for this, as compares write normal registers to 1 or 0 depending on condition.
Assuming a,b,c,d are already in registers. And maybe needed later.
cmpeq r2,r3,r4
cmpeq r5,r6,r7
and r4,r7,r7
bne r8
The best thing about alpha approach is that its reusing the normal register renaming hardware to conditions. No matter what many software people tell you, the key of optimizing is not doing more in hardware, the key of optimization is getting rid of unnecessary work. And that is what alpha version does. It removes the need for reservation stations to track condition code dependencies.
>
>
if a==b && c==d { ... }
No since that && in if statement is short circuit statement.
if((a!=null)&&(*a==b))
With any compiler trying to do that with 2 CC registers, would
remove an effect of null check that language definition states would work.
However
if((a==b)&(c==d)) is probably what you meant but its not a common way of writing that statement.
And for that to work the way you want you would need logical operations to flags registers.
That means extra read ports there and special unit to handle it.
I like the alpha way for this, as compares write normal registers to 1 or 0 depending on condition.
Assuming a,b,c,d are already in registers. And maybe needed later.
cmpeq r2,r3,r4
cmpeq r5,r6,r7
and r4,r7,r7
bne r8
The best thing about alpha approach is that its reusing the normal register renaming hardware to conditions. No matter what many software people tell you, the key of optimizing is not doing more in hardware, the key of optimization is getting rid of unnecessary work. And that is what alpha version does. It removes the need for reservation stations to track condition code dependencies.