2 /* { dg-require-effective-target sse4 } */
3 /* { dg-options "-O2 -msse4.1" } */
6 #define CHECK_H "sse4_1-check.h"
10 #define TEST sse4_1_test
15 #include <smmintrin.h>
28 compute_mpsadbw (unsigned char *v1
, unsigned char *v2
, int mask
)
39 offs2
= 4 * (mask
& 3);
40 for (i
= 0; i
< 4; i
++)
43 offs1
= 4 * ((mask
& 4) >> 2);
44 for (j
= 0; j
< 8; j
++)
47 for (i
= 0; i
< 4; i
++)
48 ret
.s
[j
] += abs (v1
[offs1
+ j
+ i
] - s
[i
]);
62 } val1
, val2
, val3
[8];
64 unsigned char masks
[8];
67 val1
.i
[0] = 0x35251505;
68 val1
.i
[1] = 0x75655545;
69 val1
.i
[2] = 0xB5A59585;
70 val1
.i
[3] = 0xF5E5D5C5;
72 val2
.i
[0] = 0x31211101;
73 val2
.i
[1] = 0x71615141;
74 val2
.i
[2] = 0xB1A19181;
75 val2
.i
[3] = 0xF1E1D1C1;
81 val3
[i
].i
[0] = 0xF1E1D1C1;
82 val3
[i
].i
[1] = 0xB1A19181;
83 val3
[i
].i
[2] = 0x71615141;
84 val3
[i
].i
[3] = 0x31211101;
91 /* Check mpsadbw imm8, xmm, xmm. */
92 res
[0] = _mm_mpsadbw_epu8 (val1
.x
, val2
.x
, msk0
);
93 res
[1] = _mm_mpsadbw_epu8 (val1
.x
, val2
.x
, msk1
);
94 res
[2] = _mm_mpsadbw_epu8 (val1
.x
, val2
.x
, msk2
);
95 res
[3] = _mm_mpsadbw_epu8 (val1
.x
, val2
.x
, msk3
);
96 res
[4] = _mm_mpsadbw_epu8 (val1
.x
, val2
.x
, msk4
);
97 res
[5] = _mm_mpsadbw_epu8 (val1
.x
, val2
.x
, msk5
);
98 res
[6] = _mm_mpsadbw_epu8 (val1
.x
, val2
.x
, msk6
);
99 res
[7] = _mm_mpsadbw_epu8 (val1
.x
, val2
.x
, msk7
);
110 for (i
=0; i
< 8; i
++)
112 tmp
= compute_mpsadbw (val1
.c
, val2
.c
, masks
[i
]);
113 if (memcmp (&tmp
, &res
[i
], sizeof (tmp
)))
117 /* Check mpsadbw imm8, m128, xmm. */
118 for (i
=0; i
< 8; i
++)
120 res
[i
] = _mm_mpsadbw_epu8 (val1
.x
, val3
[i
].x
, msk4
);
124 for (i
=0; i
< 8; i
++)
126 tmp
= compute_mpsadbw (val1
.c
, val3
[i
].c
, masks
[i
]);
127 if (memcmp (&tmp
, &res
[i
], sizeof (tmp
)))