2 /* { dg-require-effective-target avx2 } */
3 /* { dg-options "-O2 -mavx2" } */
6 #include "avx2-check.h"
19 compute_mpsadbw (int *i1
, int *i2
, int mask
, int *r
)
24 unsigned char *v1
= (char *) i1
;
25 unsigned char *v2
= (char *) i2
;
26 unsigned short *ret
= (unsigned short *) r
;
31 offs2
= 4 * (mask
& 3);
32 for (i
= 0; i
< 4; i
++)
35 offs1
= 4 * ((mask
& 4) >> 2);
36 for (j
= 0; j
< 8; j
++)
37 for (i
= 0; i
< 4; i
++)
38 ret
[j
] += abs (v1
[offs1
+ j
+ i
] - s
[i
]);
41 offs2
= 4 * ((mask
>> 3) & 3) + 16;
42 for (i
= 0; i
< 4; i
++)
45 offs1
= 4 * ((mask
& 0x20) >> 5) + 16;
46 for (j
= 0; j
< 8; j
++)
47 for (i
= 0; i
< 4; i
++)
48 ret
[j
+ 8] += abs (v1
[offs1
+ j
+ i
] - s
[i
]);
54 union256i_d val1
, val2
, val3
[8], res
[8];
56 unsigned char masks
[8];
59 val1
.a
[0] = 0x35251505;
60 val1
.a
[1] = 0x75655545;
61 val1
.a
[2] = 0xB5A59585;
62 val1
.a
[3] = 0xF5E5D5C5;
64 val1
.a
[4] = 0x35251505;
65 val1
.a
[5] = 0x75655545;
66 val1
.a
[6] = 0xB5A59585;
67 val1
.a
[7] = 0xF5E5D5C5;
69 val2
.a
[0] = 0x31211101;
70 val2
.a
[1] = 0x71615141;
71 val2
.a
[2] = 0xB1A19181;
72 val2
.a
[3] = 0xF1E1D1C1;
74 val2
.a
[4] = 0x31211101;
75 val2
.a
[5] = 0x71615141;
76 val2
.a
[6] = 0xB1A19181;
77 val2
.a
[7] = 0xF1E1D1C1;
79 for (i
= 0; i
< 8; i
++)
83 val3
[i
].a
[0] = 0xF1E1D1C1;
84 val3
[i
].a
[1] = 0xB1A19181;
85 val3
[i
].a
[2] = 0x71615141;
86 val3
[i
].a
[3] = 0x31211101;
93 /* Check mpsadbw imm8, ymm, ymm. */
94 res
[0].x
= _mm256_mpsadbw_epu8 (val1
.x
, val2
.x
, msk0
);
95 res
[1].x
= _mm256_mpsadbw_epu8 (val1
.x
, val2
.x
, msk1
);
96 res
[2].x
= _mm256_mpsadbw_epu8 (val1
.x
, val2
.x
, msk2
);
97 res
[3].x
= _mm256_mpsadbw_epu8 (val1
.x
, val2
.x
, msk3
);
98 res
[4].x
= _mm256_mpsadbw_epu8 (val1
.x
, val2
.x
, msk4
);
99 res
[5].x
= _mm256_mpsadbw_epu8 (val1
.x
, val2
.x
, msk5
);
100 res
[6].x
= _mm256_mpsadbw_epu8 (val1
.x
, val2
.x
, msk6
);
101 res
[7].x
= _mm256_mpsadbw_epu8 (val1
.x
, val2
.x
, msk7
);
112 for (i
= 0; i
< 8; i
++)
114 compute_mpsadbw (val1
.a
, val2
.a
, masks
[i
], tmp
);
115 if (check_union256i_d (res
[i
], tmp
))
119 /* Check mpsadbw imm8, m256, ymm. */
120 for (i
= 0; i
< 8; i
++)
122 res
[i
].x
= _mm256_mpsadbw_epu8 (val1
.x
, val3
[i
].x
, msk4
);
126 for (i
= 0; i
< 8; i
++)
128 compute_mpsadbw (val1
.a
, val3
[i
].a
, masks
[i
], tmp
);
129 if (check_union256i_d (res
[i
], tmp
))