| 1 |
// https://issues.dlang.org/show_bug.cgi?id=16488 |
| 2 |
// { dg-additional-options "-mavx2" { target avx2_runtime } } |
| 3 |
// { dg-do run { target { avx2_runtime || vect_sizes_32B_16B } } } |
| 4 |
// { dg-skip-if "needs gcc/config.d" { ! d_runtime } } |
| 5 |
import core.simd; |
| 6 |
|
| 7 |
void foo_byte32(byte t, byte s) |
| 8 |
{ |
| 9 |
byte32 f = s; |
| 10 |
auto p = cast(byte*)&f; |
| 11 |
foreach (i; 0 .. 32) |
| 12 |
assert(p[i] == s); |
| 13 |
} |
| 14 |
|
| 15 |
void foo_ubyte32(ubyte t, ubyte s) |
| 16 |
{ |
| 17 |
ubyte32 f = s; |
| 18 |
auto p = cast(ubyte*)&f; |
| 19 |
foreach (i; 0 .. 32) |
| 20 |
assert(p[i] == s); |
| 21 |
} |
| 22 |
|
| 23 |
void foo_short16(short t, short s) |
| 24 |
{ |
| 25 |
short16 f = s; |
| 26 |
auto p = cast(short*)&f; |
| 27 |
foreach (i; 0 .. 16) |
| 28 |
assert(p[i] == s); |
| 29 |
} |
| 30 |
|
| 31 |
void foo_ushort16(ushort t, ushort s) |
| 32 |
{ |
| 33 |
ushort16 f = s; |
| 34 |
auto p = cast(ushort*)&f; |
| 35 |
foreach (i; 0 .. 16) |
| 36 |
assert(p[i] == s); |
| 37 |
} |
| 38 |
|
| 39 |
void foo_int8(int t, int s) |
| 40 |
{ |
| 41 |
int8 f = s; |
| 42 |
auto p = cast(int*)&f; |
| 43 |
foreach (i; 0 .. 8) |
| 44 |
assert(p[i] == s); |
| 45 |
} |
| 46 |
|
| 47 |
void foo_uint8(uint t, uint s, uint u) |
| 48 |
{ |
| 49 |
uint8 f = s; |
| 50 |
auto p = cast(uint*)&f; |
| 51 |
foreach (i; 0 .. 8) |
| 52 |
assert(p[i] == s); |
| 53 |
} |
| 54 |
|
| 55 |
void foo_long4(long t, long s, long u) |
| 56 |
{ |
| 57 |
long4 f = s; |
| 58 |
auto p = cast(long*)&f; |
| 59 |
foreach (i; 0 .. 4) |
| 60 |
assert(p[i] == s); |
| 61 |
} |
| 62 |
|
| 63 |
void foo_ulong4(ulong t, ulong s) |
| 64 |
{ |
| 65 |
ulong4 f = s; |
| 66 |
auto p = cast(ulong*)&f; |
| 67 |
foreach (i; 0 .. 4) |
| 68 |
assert(p[i] == s); |
| 69 |
} |
| 70 |
|
| 71 |
void foo_float8(float t, float s) |
| 72 |
{ |
| 73 |
float8 f = s; |
| 74 |
auto p = cast(float*)&f; |
| 75 |
foreach (i; 0 .. 8) |
| 76 |
assert(p[i] == s); |
| 77 |
} |
| 78 |
|
| 79 |
void foo_double4(double t, double s, double u) |
| 80 |
{ |
| 81 |
double4 f = s; |
| 82 |
auto p = cast(double*)&f; |
| 83 |
foreach (i; 0 .. 4) |
| 84 |
assert(p[i] == s); |
| 85 |
} |
| 86 |
|
| 87 |
void main() |
| 88 |
{ |
| 89 |
foo_byte32(5, -10); |
| 90 |
foo_ubyte32(5, 11); |
| 91 |
|
| 92 |
foo_short16(5, -6); |
| 93 |
foo_short16(5, 7); |
| 94 |
|
| 95 |
foo_int8(5, -6); |
| 96 |
foo_uint8(5, 0x12345678, 22); |
| 97 |
|
| 98 |
foo_long4(5, -6, 1); |
| 99 |
foo_ulong4(5, 0x12345678_87654321L); |
| 100 |
|
| 101 |
foo_float8(5, -6); |
| 102 |
foo_double4(5, -6, 2); |
| 103 |
} |