core.simd woes
Iain Buclaw
ibuclaw at ubuntu.com
Mon Oct 8 13:05:40 PDT 2012
On 7 October 2012 13:12, Manu <turkeyman at gmail.com> wrote:
> On 5 October 2012 14:46, Iain Buclaw <ibuclaw at ubuntu.com> wrote:
>>
>> On 5 October 2012 11:28, Manu <turkeyman at gmail.com> wrote:
>> > On 3 October 2012 16:40, Iain Buclaw <ibuclaw at ubuntu.com> wrote:
>> >>
>> >> On 3 October 2012 02:31, jerro <a at a.com> wrote:
>> >> >> import core.simd, std.stdio;
>> >> >>
>> >> >> void main()
>> >> >> {
>> >> >> float4 a = 1, b = 2;
>> >> >> writeln((a + b).array); // WORKS: [3, 3, 3, 3]
>> >> >>
>> >> >> float4 c = [1, 2, 3, 4]; // ERROR: "Stored value type does
>> >> >> // not match pointer operand type!"
>> >> >> // [..a bunch of LLVM error code..]
>> >> >>
>> >> >> float4 c = 0, d = 1;
>> >> >> c.array[0] = 4;
>> >> >> c.ptr[1] = 4;
>> >> >> writeln((c + d).array); // WRONG: [1, 1, 1, 1]
>> >> >> }
>> >> >
>> >> >
>> >> > Oh, that doesn't work for me either. I never tried to use those, so I
>> >> > didn't
>> >> > notice that before. This code gives me internal compiler errors with
>> >> > GDC
>> >> > and
>> >> > DMD too (with "float4 c = [1, 2, 3, 4]" commented out). I'm using DMD
>> >> > 2.060
>> >> > and a recent versions of GDC and LDC on 64 bit Linux.
>> >>
>> >> Then don't just talk about it, raise a bug - otherwise how do you
>> >> expect it to get fixed! ( http://www.gdcproject.org/bugzilla )
>> >>
>> >> I've made a note of the error you get with `__vector(float[4]) c =
>> >> [1,2,3,4];' - That is because vector expressions implementation is
>> >> very basic at the moment. Look forward to hear from all your
>> >> experiences so we can make vector support rock solid in GDC. ;-)
>> >
>> >
>> > I didn't realise vector literals like that were supported properly in
>> > the
>> > front end yet?
>> > Do they work at all? What does the code generated look like?
>>
>> They get passed to the backend as of 2.060 - so looks like the
>> semantic passes now allow them.
>>
>> I've just recently added backend support in GDC -
>>
>> https://github.com/D-Programming-GDC/GDC/commit/7ada3d95b8af1b271d82f1ec5208f0b689eb143c#L1R1194
>>
>> The codegen looks like so:
>>
>> float4 a = 2;
>> float4 b = [1,2,3,4];
>>
>> ==>
>> vector(4) float a = { 2.0e+0, 2.0e+0, 2.0e+0, 2.0e+0 };
>> vector(4) float b = { 1.0e+0, 2.0e+0, 3.0e+0, 4.0e+0 };
>>
>> ==>
>> movaps .LC0, %xmm0
>> movaps %xmm0, -24(%ebp)
>> movaps .LC1, %xmm0
>> movaps %xmm0, -40(%ebp)
>>
>> .align 16
>> .LC0:
>> .long 1073741824
>> .long 1073741824
>> .long 1073741824
>> .long 1073741824
>> .align 16
>> .LC1:
>> .long 1065353216
>> .long 1073741824
>> .long 1077936128
>> .long 1082130432
>
>
> Perfect!
> I can get on with my unittests :P
I fixed them again.
https://github.com/D-Programming-GDC/GDC/commit/9402516e0b07031e841a15849f5dc94ae81dccdc#L4R1201
float a = 1, b = 2, c = 3, d = 4;
float4 f = [a,b,c,d];
===>
movss -16(%rbp), %xmm0
movss -12(%rbp), %xmm1
Regards
--
Iain Buclaw
*(p < e ? p++ : p) = (c & 0x0f) + '0';
More information about the Digitalmars-d
mailing list