Simple example:
T opCompound(string seq)(T a, T b, T c) if(seq == "* +") {
return
_madd(a, b, c); }
It may be useful to have a way to define compound operators for
other things (although you can already write expression
templates), but this is an optimization that the compiler back
end can do. If you compile this code:
float4 foo(float4 a, float4 b, float4 c){ return a * b + c; }
With gdc with flags -O2 -fma, you get:
0000000000000000 <_D3tmp3fooFNhG4fNhG4fNhG4fZNhG4f>:
0: c4 e2 69 98 c1 vfmadd132ps xmm0,xmm2,xmm1
5: c3 ret