Hi, while porting gst-plugins-gl shaders to work with i915 I've passed some time looking at the programs produced by the compiler (with MESA_GLSL=log) and noticed that statements like
a += b * c;
MUL C, B, C;
ADD A, A, C;
a = b * c + a;
MAD A, B, C, A;
I don't know how this works in hardware but I guess the latter has a dedicated path and is more efficient or, at least, saves up an instruction (and that's particularly important where the maximum number of instructions is little as in i915).
For what is worth, assembly produced by nVidia's Cg uses MAD in both cases.
Not sure if this is valid elsewhere too in mesa, tested it with i915 only.
Yeah, this is the sort of thing that the codegen in the new compiler will handle very easily but which is a pain to do in Mesa today.
On the glsl2 branch:
Author: Eric Anholt <firstname.lastname@example.org>
Date: Mon Jul 12 19:28:07 2010 -0700
ir_to_mesa: Emit OPCODE_MAD when we find an ADD of a MUL.
GLSL2 branch is now merged.