By: Michael S (already5chosen.delete@this.yahoo.com), July 7, 2015 1:07 am
Room: Moderated Discussions
Patrick Chase (patrickjchase.delete@this.gmai.com) on July 6, 2015 10:31 pm wrote:
> Linus Torvalds (torvalds.delete@this.linux-foundation.org) on July 6, 2015 3:59 pm wrote:
> > x86 doesn't have those insane memory ordering semantics. Loads are done in order (as far
> > as software could tell - they do get re-ordered, but the semantics are guaranteed to be
> > the same as if they were done in order), so it doesn't matter if the two accessed had a
> > data or control dependency between them.
>
> And yet you yourself have (very effectively, with real data) made the argument that cmov seldom pays on x86.
>
Actually, that's his whole point.
Conditional moves and other similar branch avoidance techniques seldom pays on x86 or everywhere because, except few special cases, we can't anticipate predictability and on average predictability is better than suggested by [untrained] intuition of programmer.
So, says Linus, let's tell compiler to emit conditional moves at any half-sane opportunity nevertheless and solve the problem in hardware, by dynamically converting easily predictable conditional moves into branches!
The idea is similar to IBM's dynamic conversion of poorly predictable branches into conditional moves.
I didn't try to think about advantages and disadvantages of either of these approaches. At the first glance they look equivalent.
> Linus Torvalds (torvalds.delete@this.linux-foundation.org) on July 6, 2015 3:59 pm wrote:
> > x86 doesn't have those insane memory ordering semantics. Loads are done in order (as far
> > as software could tell - they do get re-ordered, but the semantics are guaranteed to be
> > the same as if they were done in order), so it doesn't matter if the two accessed had a
> > data or control dependency between them.
>
> And yet you yourself have (very effectively, with real data) made the argument that cmov seldom pays on x86.
>
Actually, that's his whole point.
Conditional moves and other similar branch avoidance techniques seldom pays on x86 or everywhere because, except few special cases, we can't anticipate predictability and on average predictability is better than suggested by [untrained] intuition of programmer.
So, says Linus, let's tell compiler to emit conditional moves at any half-sane opportunity nevertheless and solve the problem in hardware, by dynamically converting easily predictable conditional moves into branches!
The idea is similar to IBM's dynamic conversion of poorly predictable branches into conditional moves.
I didn't try to think about advantages and disadvantages of either of these approaches. At the first glance they look equivalent.