PR target/80969 - Fix ICE with -mabi=ms -mavx512f, reduce wasted space when realignin...
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4a-insert.c
blob7d9ec48d70c7523bdcb7ead655ea052c4689498f
1 /* { dg-do run } */
2 /* { dg-require-effective-target sse4a } */
3 /* { dg-options "-O2 -msse4a" } */
5 #include "sse4a-check.h"
7 #include <ammintrin.h>
9 typedef union
11 long long i[2];
12 __m128i vec;
13 } LI;
15 static long long
16 sse4a_test_insert (long long in1, long long in2)
18 __m128i v1,v2;
19 long long index_length, pad;
20 LI v_out;
21 index_length = 0x0000000000000810LL;
22 pad = 0x0;
23 v1 = _mm_set_epi64x (pad, in1);
24 v2 = _mm_set_epi64x (index_length, in2);
25 v_out.vec = _mm_insert_si64 (v1, v2);
26 return (v_out.i[0]);
29 static long long
30 sse4a_test_inserti (long long in1, long long in2)
32 __m128i v1,v2;
33 long long pad = 0x0;
34 LI v_out;
35 v1 = _mm_set_epi64x (pad, in1);
36 v2 = _mm_set_epi64x (pad, in2);
37 v_out.vec = _mm_inserti_si64 (v1, v2, (unsigned int) 0x10, (unsigned int) 0x08);
38 return (v_out.i[0]);
41 static int chk (long long i1, long long i2)
43 int n_fails =0;
44 if (i1 != i2)
45 n_fails +=1;
46 return n_fails;
49 long long vals_in1[5] =
51 0x1234567887654321LL,
52 0x1456782093002490LL,
53 0x2340909123990390LL,
54 0x9595959599595999LL,
55 0x9099038798000029LL
58 long long vals_in2[5] =
60 0x9ABCDEF00FEDCBA9LL,
61 0x234567097289672ALL,
62 0x45476453097BD342LL,
63 0x23569012AE586FF0LL,
64 0x432567ABCDEF765DLL
67 long long vals_out[5] =
69 0x1234567887CBA921LL,
70 0x1456782093672A90LL,
71 0x2340909123D34290LL,
72 0x95959595996FF099LL,
73 0x9099038798765D29LL
76 static void
77 sse4a_test (void)
79 int i;
80 int fail = 0;
81 long long out;
83 for (i = 0; i < 5; i += 1)
85 out = sse4a_test_insert (vals_in1[i], vals_in2[i]);
86 fail += chk(out, vals_out[i]);
88 out = sse4a_test_inserti (vals_in1[i], vals_in2[i]);
89 fail += chk(out, vals_out[i]);
92 if (fail != 0)
93 abort ();