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" } } */ 6 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 } } } } */ 11 12/* { dg-final { scan-assembler-times "tst" 442 { target { sh2a } } } } */ 13/* { dg-final { scan-assembler-times "bld" 276 { target { sh2a } } } } */ 14/* { dg-final { scan-assembler-times "cmp/pz" 6 { target { sh2a } } } } */ 15/* { dg-final { scan-assembler-times "shll\t" 4 { target { sh2a } } } } */ 16/* { dg-final { scan-assembler-times "shlr\t" 8 { target { sh2a } } } } */ 17 18/* { dg-final { scan-assembler-times "and\t#1" 32 } } */ 19 20#define make_func(type,shift)\ 21 int test_##type##_##_shift_##shift##_0 (type x)\ 22 {\ 23 return ((x >> shift) ^ 1) & 1 ? -40 : -10;\ 24 }\ 25 int test_##type##_##_shift_##shift##_1 (type x)\ 26 {\ 27 return ((x >> shift) ^ 0) & 1 ? -40 : -10;\ 28 }\ 29 int test_##type##_##_shift_##shift##_2 (type x)\ 30 {\ 31 return ((x >> shift) ^ 1) & 1;\ 32 }\ 33 int test_##type##_##_shift_##shift##_3 (type x)\ 34 {\ 35 return ((x >> shift) ^ 0) & 1;\ 36 }\ 37 int test_##type##_##_shift_##shift##_4 (type x)\ 38 {\ 39 return (x & (1 << shift)) == 0;\ 40 }\ 41 int test_##type##_##_shift_##shift##_5 (type x)\ 42 {\ 43 return (x & (1 << shift)) != 0;\ 44 }\ 45\ 46 int test_##type##_##_shift_##shift##_6 (type* x)\ 47 {\ 48 return ((*x >> shift) ^ 1) & 1 ? -40 : -10;\ 49 }\ 50 int test_##type##_##_shift_##shift##_7 (type* x)\ 51 {\ 52 return ((*x >> shift) ^ 0) & 1 ? -40 : -10;\ 53 }\ 54 int test_##type##_##_shift_##shift##_8 (type* x)\ 55 {\ 56 return ((*x >> shift) ^ 1) & 1;\ 57 }\ 58 int test_##type##_##_shift_##shift##_9 (type* x)\ 59 {\ 60 return ((*x >> shift) ^ 0) & 1;\ 61 }\ 62 int test_##type##_##_shift_##shift##_10 (type* x)\ 63 {\ 64 return (*x & (1 << shift)) == 0;\ 65 }\ 66 int test_##type##_##_shift_##shift##_11 (type* x)\ 67 {\ 68 return (*x & (1 << shift)) != 0;\ 69 } 70 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) 80 81typedef signed char int8_t; 82typedef unsigned char uint8_t; 83typedef signed short int16_t; 84typedef unsigned short uint16_t; 85typedef signed int int32_t; 86typedef unsigned int uint32_t; 87typedef signed long long int64_t; 88typedef unsigned long long uint64_t; 89 90make_funcs (int8_t) 91make_funcs (uint8_t) 92make_funcs (int16_t) 93make_funcs (uint16_t) 94make_funcs (int32_t) 95make_funcs (uint32_t) 96make_funcs (int64_t) 97make_funcs (uint64_t) 98