On 8 January 2012 02:54, Peter Alexander <peter.alexander...@gmail.com>wrote:

> I agree with Manu that we should just have a single type like __m128 in
> MSVC. The other types and their conversions should be solvable in a library
> with something like strong typedefs.
>

Walter put in a reasonable effort to sway me to his side of the fence last
night. I'm still not entirely sold that implementation inside the language
is necessary to achieve these details, but I don't have enough background
into to argue, and I'm not the one that has to maintain the code :)

Here are some points we discussed... how do we do these (efficiently) in a
library?

** Literal syntax.. and constant folding:

Constants and literals also need to be aligned. If we use array syntax to
express literals, this will be a problem.

 int4 v = [ 1,2,3,4 ] + [ 5,6,7,8 ];

Any constant expressions need to be simplified at compile time: int4 vec =
[ 6,8,10,12 ];
Perhaps this is possible with CTFE? Or will it be automatic if you express
literals as if they were arrays?

** Expression interpretation/simplification:

 float4 v = -b + a;

Obviously, this should be simplified to 'a - b'.

 float4 v = a*b + c;

This should use a multiply-accumulate opcode on most architectures: FMADDPS
v, a, b, c

** Typed debug info

In a debugger it's nice to inspect variables in their supposed type.
Can probably use unions to do this... probably wouldn't be as nice though.

** God knows what other optimisations

float4 v = [ 0,0,0,0 ]; // XOR v
etc...


I don't know what amount of this is achievable with libraries, but Walter
seems to think this will all work much better in the language... I'm
inclined to trust his judgement.

Reply via email to