Bug 15145 – Array initializers for SIMD not working inside functions.
Status
RESOLVED
Resolution
INVALID
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-10-03T16:44:00Z
Last change time
2016-04-26T12:54:02Z
Keywords
rejects-valid, SIMD
Assigned to
nobody
Creator
Marco.Leise
Comments
Comment #0 by Marco.Leise — 2015-10-03T16:44:51Z
Practically this compiles:
import core.simd, std.range, std.array;
ubyte[16] a = ubyte(16).iota.array;
ubyte16 b = ubyte(16).iota.array;
But simply moving the definition inside a function does not work:
void main()
{
import core.simd, std.range, std.array;
ubyte16 b = ubyte(16).iota.array;
}
Error: cannot implicitly convert expression (array(iota(cast(ubyte)16u))) of type ubyte[] to __vector(ubyte[16])
To be fair it works when you declare the vector as static, and that should probably be done for performance, but it should not be an error and the message is too general, as it works for static/global vectors.
Comment #1 by bugzilla — 2016-04-25T09:24:58Z
It looks like CTFE is evaluating it, and hence can determine the array dimensions so it can be converted. For the runtime evaluation, the array dimension is not available.
Not sure what to do about this - D isn't supposed to speculatively attempt to CTFE expressions meant to be evaluated at runtime.
Comment #2 by Marco.Leise — 2016-04-26T12:54:02Z
Ah right, now that you say it. I thought it had to do with handling of SSE types in the compiler. I close it as invalid then.