1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
4 
5 #define AVX512F
6 
7 #include "avx512f-helper.h"
8 
9 #define SIZE (AVX512F_LEN / 32)
10 #include "avx512f-mask-type.h"
11 #include "string.h"
12 
13 void static
CALC(UNION_TYPE (AVX512F_LEN,i_d)s1,union128i_d s2,int * res_ref,int imm)14 CALC (UNION_TYPE (AVX512F_LEN, i_d) s1, union128i_d s2, int *res_ref, int imm)
15 {
16   memcpy (res_ref, s1.a, SIZE * sizeof (int));
17   memcpy (res_ref + imm * 4, s2.a, 16);
18 }
19 
20 void
TEST(void)21 TEST (void)
22 {
23   UNION_TYPE (AVX512F_LEN, i_d) s1, res1, res2, res3;
24   union128i_d s2;
25   int res_ref[SIZE];
26   int j;
27 
28   MASK_TYPE mask = 6 ^ (0xffd >> SIZE);
29 
30   for (j = 0; j < SIZE; j++)
31     {
32       s1.a[j] = j * j;
33       res1.a[j] = DEFAULT_VALUE;
34       res2.a[j] = DEFAULT_VALUE;
35       res3.a[j] = DEFAULT_VALUE;
36     }
37 
38   for (j = 0; j < 4; j++)
39     s2.a[j] = j * j * j;
40 
41   res1.x = INTRINSIC (_inserti32x4) (s1.x, s2.x, 1);
42   res2.x = INTRINSIC (_mask_inserti32x4) (res2.x, mask, s1.x, s2.x, 1);
43   res3.x = INTRINSIC (_maskz_inserti32x4) (mask, s1.x, s2.x, 1);
44 
45   CALC (s1, s2, res_ref, 1);
46 
47   if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref))
48     abort ();
49 
50   MASK_MERGE (i_d) (res_ref, mask, SIZE);
51 
52   if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref))
53     abort ();
54 
55   MASK_ZERO (i_d) (res_ref, mask, SIZE);
56 
57   if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref))
58     abort ();
59 }
60