2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / bmi-bextr-6.c
blob589596744558db94004a4ee787dba2528333155b
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -mbmi -fdump-tree-optimized" } */
3 /* { dg-final { scan-tree-dump-not "link_error" "optimized" } } */
5 #include <x86intrin.h>
7 extern void link_error (void);
9 volatile unsigned int a;
10 volatile unsigned long long b;
12 int
13 main ()
15 if (__bextr_u32 (0xffffffffU, 0 | (0 << 8)) != 0
16 || __bextr_u32 (0xffffffffU, 64 | (16 << 8)) != 0
17 || __bextr_u32 (0x12345678U, 4 | (10 << 8)) != 0x167
18 || __bextr_u32 (0xffffffffU, 2 | (255 << 8)) != 0x3fffffff
19 || __bextr_u32 (0xdeadbeefU, 2 | (64 << 8)) != 0x37ab6fbb
20 || __bextr_u32 (0xdeadbeefU, 0 | (64 << 8)) != 0xdeadbeefU
21 || __bextr_u32 (a, 0 | (0 << 8)) != 0
22 || __bextr_u32 (a, 32 | (16 << 8)) != 0)
23 link_error ();
24 if (_bextr_u32 (0xffffffffU, 0, 0) != 0
25 || _bextr_u32 (0xffffffffU, 64, 16) != 0
26 || _bextr_u32 (0x12345678U, 4, 10) != 0x167
27 || _bextr_u32 (0xffffffffU, 2, 255) != 0x3fffffff
28 || _bextr_u32 (0xdeadbeefU, 2, 64) != 0x37ab6fbb
29 || _bextr_u32 (0xdeadbeefU, 0, 64) != 0xdeadbeefU
30 || _bextr_u32 (a, 0, 0) != 0
31 || _bextr_u32 (a, 32, 16) != 0)
32 link_error ();
33 #ifdef __x86_64__
34 if (__bextr_u64 (0xffffffffffffffffUL, 0 | (0 << 8)) != 0
35 || __bextr_u64 (0xffffffffffffffffUL, 128 | (16 << 8)) != 0
36 || __bextr_u64 (0x123456789abcdef0UL, 5 | (37 << 8)) != 0x13c4d5e6f7UL
37 || __bextr_u64 (0xffffffffffffffffUL, 2 | (255 << 8)) != 0x3fffffffffffffffUL
38 || __bextr_u64 (0xdeadbeefbeefdeadU, 2 | (64 << 8)) != 0x37ab6fbbefbbf7abUL
39 || __bextr_u64 (0xdeadbeefbeefdeadU, 0 | (64 << 8)) != 0xdeadbeefbeefdeadUL
40 || __bextr_u64 (b, 0 | (0 << 8)) != 0
41 || __bextr_u64 (b, 64 | (16 << 8)) != 0)
42 link_error ();
43 if (_bextr_u64 (0xffffffffffffffffUL, 0, 0) != 0
44 || _bextr_u64 (0xffffffffffffffffUL, 128, 16) != 0
45 || _bextr_u64 (0x123456789abcdef0UL, 5, 37) != 0x13c4d5e6f7UL
46 || _bextr_u64 (0xffffffffffffffffUL, 2, 255) != 0x3fffffffffffffffUL
47 || _bextr_u64 (0xdeadbeefbeefdeadUL, 2, 64) != 0x37ab6fbbefbbf7abUL
48 || _bextr_u64 (0xdeadbeefbeefdeadUL, 0, 64) != 0xdeadbeefbeefdeadUL
49 || _bextr_u64 (b, 0, 0) != 0
50 || _bextr_u64 (b, 64, 16) != 0)
51 link_error ();
52 #endif
53 return 0;