2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / testsuite / gcc.target / sh / pr64345-1.c
blob64757ff8cd129b1ed8b0aff260c6df99b75edba6
1 /* Verify that single bit zero extractions emit the expected
2 insns sequences. */
3 /* { dg-do compile } */
4 /* { dg-options "-O2" } */
5 /* { dg-final { scan-assembler-not "exts|extu|sha|shld|subc|xor" } } */
7 /* { dg-final { scan-assembler-times "tst" 716 { target { ! sh2a } } } } */
8 /* { dg-final { scan-assembler-times "cmp/pz" 6 { target { ! sh2a } } } } */
9 /* { dg-final { scan-assembler-times "shll\t" 6 { target { ! sh2a } } } } */
10 /* { dg-final { scan-assembler-times "shlr\t" 8 { target { ! sh2a } } } } */
12 /* { dg-final { scan-assembler-times "tst" 442 { target { sh2a } } } } */
13 /* { dg-final { scan-assembler-times "bld" 285 { target { sh2a } } } } */
14 /* { dg-final { scan-assembler-times "cmp/pz" 6 { target { sh2a } } } } */
15 /* { dg-final { scan-assembler-times "shll\t" 3 { target { sh2a } } } } */
16 /* { dg-final { scan-assembler-times "shlr\t" 0 { target { sh2a } } } } */
18 /* { dg-final { scan-assembler-times "and\t#1" 32 } } */
20 #define make_func(type,shift)\
21 int test_##type##_##_shift_##shift##_0 (type x)\
23 return ((x >> shift) ^ 1) & 1 ? -40 : -10;\
25 int test_##type##_##_shift_##shift##_1 (type x)\
27 return ((x >> shift) ^ 0) & 1 ? -40 : -10;\
29 int test_##type##_##_shift_##shift##_2 (type x)\
31 return ((x >> shift) ^ 1) & 1;\
33 int test_##type##_##_shift_##shift##_3 (type x)\
35 return ((x >> shift) ^ 0) & 1;\
37 int test_##type##_##_shift_##shift##_4 (type x)\
39 return (x & (1 << shift)) == 0;\
41 int test_##type##_##_shift_##shift##_5 (type x)\
43 return (x & (1 << shift)) != 0;\
46 int test_##type##_##_shift_##shift##_6 (type* x)\
48 return ((*x >> shift) ^ 1) & 1 ? -40 : -10;\
50 int test_##type##_##_shift_##shift##_7 (type* x)\
52 return ((*x >> shift) ^ 0) & 1 ? -40 : -10;\
54 int test_##type##_##_shift_##shift##_8 (type* x)\
56 return ((*x >> shift) ^ 1) & 1;\
58 int test_##type##_##_shift_##shift##_9 (type* x)\
60 return ((*x >> shift) ^ 0) & 1;\
62 int test_##type##_##_shift_##shift##_10 (type* x)\
64 return (*x & (1 << shift)) == 0;\
66 int test_##type##_##_shift_##shift##_11 (type* x)\
68 return (*x & (1 << shift)) != 0;\
71 #define make_funcs(type)\
72 make_func (type, 0)\
73 make_func (type, 1)\
74 make_func (type, 2)\
75 make_func (type, 3)\
76 make_func (type, 4)\
77 make_func (type, 5)\
78 make_func (type, 6)\
79 make_func (type, 7)
81 typedef signed char int8_t;
82 typedef unsigned char uint8_t;
83 typedef signed short int16_t;
84 typedef unsigned short uint16_t;
85 typedef signed int int32_t;
86 typedef unsigned int uint32_t;
87 typedef signed long long int64_t;
88 typedef unsigned long long uint64_t;
90 make_funcs (int8_t)
91 make_funcs (uint8_t)
92 make_funcs (int16_t)
93 make_funcs (uint16_t)
94 make_funcs (int32_t)
95 make_funcs (uint32_t)
96 make_funcs (int64_t)
97 make_funcs (uint64_t)