www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8543] New: simd literals need better CTFE support

http://d.puremagic.com/issues/show_bug.cgi?id=8543

           Summary: simd literals need better CTFE support
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: WorksOnMyMachine gmail.com


--- Comment #0 from Sean Cavanaugh <WorksOnMyMachine gmail.com> 2012-08-12
13:56:18 PDT ---
Making a struct wrapper around the core vector types like core.simd.float4:

struct vfloat
{
public:
    float4 f32;

    this(float X) nothrow
    {
        f32.ptr[0] = X;
        f32.ptr[1] = X;
        f32.ptr[2] = X;
        f32.ptr[3] = X;
    }
    this(float X, float Y, float Z, float W) nothrow
    {
        f32.array[0] = X;
        f32.array[1] = Y;
        f32.array[2] = Z;
        f32.array[3] = W;
    }
    this(float[4] values) nothrow
    {
        f32 = values;
    }
}

none of these constructors are callable for global constants:

immutable auto GvfGlobal_ThreeA = vfloat(3.0f);
immutable auto GvfGlobal_ThreeB = vfloat(3.0f, 3.0f, 3.0f, 3.0f);
immutable auto GvfGlobal_ThreeC = vfloat([3.0f, 3.0f, 3.0f, 3.0f]);



vmath\sse\sse_vfloat.d(22): Error: cannot cast vfloat(nanF).f32 to float[4u] at
compile time
vmath\sse\sse_globals.d(39):        called from here: vfloat(nanF).this(3F)


vmath\sse\sse_globals.d(40): Error: cannot cast float to float[4u]
vmath\sse\sse_vfloat.d(29): Error: cannot determine length of
cast(float[4u])this.f32 at compile time
vmath\sse\sse_globals.d(40):        called from here:
vfloat(nanF).this(3F,3F,3F,3F)


vmath\sse\sse_vfloat.d(36): Error: cannot implicitly convert expression
(values) of type float[4u] to __vector(float[4u])
vmath\sse\sse_globals.d(41):        called from here:
vfloat(nanF).this([3F,3F,3F,3F])


I also tried to coerce the constructor arguments into a float4 and perform
assignment like so:

float4 foo = [X,X,X,X];

and also got : vmath\sse\sse_vfloat.d(22): Error: Cannot interpret
cast(__vector(float[4u]))[X,X,X,X] at compile time



I also tried the following for the array constructor:

    this(float[4] values) nothrow
    {
        f32.array = values;
    }

This returned the following error:

vmath\sse\sse_vfloat.d(37): Error: CTFE ICE: cannot resolve array length

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 12 2012