Well, the difficulty in knowing that, and keeping track of which GPU can do which operations, is part of the reason that newer architectures aren't vectorized (in the same way). Rather than doing instruction-level parallelism (with things like dot product and multiply-add on a float4), all operations are standard scalar floating point. Instead, the GPU runs the same scalar math on more threads in parallel (clusters of pixels or vertices). The end result is that - in general - micro-optimizing the order of operations is less important, because you can really just think about the naturally correct math to get what you need.

Example: It used to make sense to accumulate lighting information from four lights in parallel, in a transposed fashion. Doing work per light meant that you were operating on three of the four channels (rgb/xyz) while doing your math. That was basically wasting 1/4 of your potential ALU. So you'd accumulate all of the red contribution in one variable, green in another, etc... And you'd do it for four lights (one in each channel of those variables). That got you up to a 33% speedup.

On the scalar GPUs, that kind of optimization does nothing - you're still doing the same number of basic operations to accumulate the final result, and because everything is broken down to scalar pieces (a 3 component dot product takes a multiply and two multiply-adds), the total number of operations doesn't change.

I think the presentations by Humus give a good level of insight into what the compiler can/can't do, and what's typically fast. The #1 thing to remember is that GPUs have a multiply-then-add instruction, but not add-then-multiply. Always move your constant biases through your scale factors to take advantage of that. And things like combining lots of linear operations into a single matrix operation is going to get you lots more performance than worrying about whether to use lerp or not - if lerp correctly describes the math you want to do, you need to trust that it's going to be implemented using the best available instructions on each GPU.

**Edited by osmanb, 20 September 2014 - 08:46 AM.**