Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / bmi-bextr-5.c
blobfd6e3620fab824cc1ee67cbfe7c9f3fd583b148d
1 /* { dg-do run { target { bmi && { ! ia32 } } } } */
2 /* { dg-options "-O2 -mbmi -fno-inline" } */
4 #include <x86intrin.h>
6 #include "bmi-check.h"
8 long long calc_bextr_u64 (unsigned long long src1,
9 unsigned long long src2)
11 long long res = 0;
12 unsigned char start = (src2 & 0xff);
13 unsigned char len = (int) ((src2 >> 8) & 0xff);
14 if (start < 64) {
15 unsigned i;
16 unsigned last = (start+len) < 64 ? start+len : 64;
18 src1 >>= start;
19 for (i=start; i<last; ++i) {
20 res |= (src1 & 1) << (i-start);
21 src1 >>= 1;
25 return res;
28 static void
29 bmi_test ()
31 unsigned i;
32 unsigned char start, len;
33 unsigned long long src1 = 0xfacec0ffeefacec0;
34 unsigned long long res, res_ref, src2;
36 for (i=0; i<5; ++i) {
37 start = i * 4;
38 len = i * 3;
39 src1 = src1 * 3;
40 src2 = (start & 0xff) | ((len & 0xff) << 8);
42 res_ref = calc_bextr_u64 (src1, src2);
43 res = _bextr_u64 (src1, start, len);
45 if (res != res_ref)
46 abort();