By: Wilco (Wilco.Dijkstra.delete@this.ntlworld.com), February 17, 2013 11:30 am
Room: Moderated Discussions
TREZA (no.delete@this.ema.il) on February 17, 2013 11:59 am wrote:
> ⚛ (0xe2.0x9a.0x9b.delete@this.gmail.com) on February 17, 2013 10:49 am wrote:
> > > > Linus Torvalds (torvalds.delete@this.linux-foundation.org) on February
> > > > 14, 2013 4:44 pm In contrast, multiple CC registers are just stupid.
> >
> > Isn't it true that the following code could run faster with 2 CC registers:
> >
> >
> >
>
> It could be faster with in-order cores without branch prediction.
No, it can't ever be faster. You need 4 instructions whether you expand the sequence using logical operations and a branch, 2 compares and branches or 2 compares with a condition combine instruction and a branch.
However conditional execution needs 2 or 3 instructions for this, and combined compare+branch needs just 2 so those are the fastest ways on in-order CPUs.
Wilco
> ⚛ (0xe2.0x9a.0x9b.delete@this.gmail.com) on February 17, 2013 10:49 am wrote:
> > > > Linus Torvalds (torvalds.delete@this.linux-foundation.org) on February
> > > > 14, 2013 4:44 pm In contrast, multiple CC registers are just stupid.
> >
> > Isn't it true that the following code could run faster with 2 CC registers:
> >
> >
if a==b && c==d { ... }
> >
>
> It could be faster with in-order cores without branch prediction.
No, it can't ever be faster. You need 4 instructions whether you expand the sequence using logical operations and a branch, 2 compares and branches or 2 compares with a condition combine instruction and a branch.
However conditional execution needs 2 or 3 instructions for this, and combined compare+branch needs just 2 so those are the fastest ways on in-order CPUs.
Wilco