RE: kernel + gcc 4.1 = several problems

From: Linus Torvalds
Date: Thu Jan 04 2007 - 10:39:29 EST




On Thu, 4 Jan 2007, Zou, Nanhai wrote:
>
> cmov will stall on eflags in your test program.

And that is EXACTLY my point.

CMOV is a piece of CRAP for most things, exactly because it serializes
three streams of data: the two inputs, and the conditional.

My test-case was actually _good_ for cmov, because there was just the one
conditional (which was 100% ALU) thing that was serialized. In real life,
the two data sources also come from memory, and _any_ of them being
delayed ends up delaying the cmov, and screwing up your out-of-order
pipeline because you now introduced a serialization point that was very
possibly not necessary at all.

In contrast, a conditional branch-around serializes absolutely NOTHING,
because branches get predicted.

> I think you will see benefit of cmov if you can manage to put some
> instructions which does NOT modify eflags between testl and cmov.

A lot of the time, the conditional _is_ the critical path.

The whole point of this discussion was that cmov isn't really all that
great. It has fundamental problems that a conditional branch that gets
predicted simply does not have.

That's qiute apart from the fact that cmov has rather limited semantics,
and that in 99% of all cases you have to use a conditional branch anyway.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/