digitalmars.D.bugs - [Issue 20112] New: __vector casts don't do type conversions
- d-bugmail puremagic.com (29/29) Aug 06 2019 https://issues.dlang.org/show_bug.cgi?id=20112
https://issues.dlang.org/show_bug.cgi?id=20112 Issue ID: 20112 Summary: __vector casts don't do type conversions Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: thomas.bockman gmail.com This program should print 3, but instead it prints 1077936128, as if I had asked for a reinterpret cast instead of conversion. void main() { import std.stdio; __vector(float[4]) f = [3, 2, 1, 0]; __vector(int[4]) i = cast(__vector(int[4])) f; writeln(i[0]); } This problem affects nearly all combinations of component types. The compiler needs to emit actual conversion instructions, not just typed moves. From my research, the fastest combination on X86_64 with AVX seems to be: 0) VPMOVSX or VPMOVZX to extend byte, ubyte, short, or ushort 1) VCVT to convert between any combination of int, uint, long, ulong, float, or double 2) VPSHUFB to truncate int/uint or long/ulong to short/ushort or byte/ubyte --
Aug 06 2019