Bug 8543 – simd literals need better CTFE support

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-08-12T13:56:00Z
Last change time
2013-12-19T04:25:03Z
Keywords
CTFE, ice
Assigned to
nobody
Creator
WorksOnMyMachine

Comments

Comment #0 by WorksOnMyMachine — 2012-08-12T13:56:18Z
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
Comment #1 by ibuclaw — 2013-12-02T03:33:14Z
Comment #2 by github-bugzilla — 2013-12-08T20:06:21Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d9c404e5e57cf1ad075eaa0c11c908e9ea40ada1 Issue 8543 - [CTFE] simd literals need better support https://github.com/D-Programming-Language/dmd/commit/bc8454a45fe960c5f1008ea32d75b99755487117 Merge pull request #2913 from ibuclaw/issue8543 Issue 8543 - [CTFE] simd literals need better support
Comment #3 by ibuclaw — 2013-12-09T01:44:07Z
Comment #4 by github-bugzilla — 2013-12-19T04:25:03Z