1 /* Verify that TST #imm, R0 instruction is generated when the tested reg
2 is shifted by a constant amount. */
3 /* { dg-do compile } */
4 /* { dg-options "-O2" } */
5 /* { dg-final { scan-assembler-not "and|shl|sha|exts" } } */
7 /* { dg-final { scan-assembler-times "tst\t#7,r0" 3 } } */
8 /* { dg-final { scan-assembler-times "tst\t#12,r0" 1 } } */
9 /* { dg-final { scan-assembler-times "tst\t#24,r0" 6 } } */
10 /* { dg-final { scan-assembler-times "tst\t#13,r0" 3 } } */
11 /* { dg-final { scan-assembler-times "tst\t#242,r0" 3 } } */
12 /* { dg-final { scan-assembler-times "tst\t#252,r0" 1 } } */
14 /* { dg-final { scan-assembler-times "tst\t#64,r0" 6 { target { ! sh2a } } } } */
15 /* { dg-final { scan-assembler-times "tst\t#64,r0" 4 { target { sh2a } } } } */
16 /* { dg-final { scan-assembler-times "bld\t#6" 2 { target { sh2a } } } } */
19 test_00 (unsigned char* x
, int y
, int z
)
22 return (x
[0] << 4) & 192 ? y
: z
;
26 test_01 (unsigned char* x
, int y
, int z
)
29 return (x
[0] << 3) & 192 ? y
: z
;
33 test_02 (unsigned char* x
, int y
, int z
)
36 return ((x
[0] << 3) & 192) != 0;
40 test_03 (unsigned char* x
, int y
, int z
)
43 return ((x
[0] << 3) & 192) == 0;
47 test_04 (unsigned char x
, int y
, int z
)
50 return (x
<< 3) & 192 ? y
: z
;
54 test_05 (unsigned char x
, int y
, int z
)
57 return ((x
<< 3) & 192) != 0;
61 test_06 (unsigned char x
, int y
, int z
)
64 return ((x
<< 3) & 192) == 0;
68 test_07 (unsigned char x
, int y
, int z
)
71 return (x
<< 3) & 111 ? y
: z
;
75 test_08 (unsigned char x
, int y
, int z
)
78 return ((x
<< 3) & 111) != 0;
82 test_09 (unsigned char x
, int y
, int z
)
85 return ((x
<< 3) & 111) == 0;
89 test_10 (unsigned char x
, int y
, int z
)
92 return (x
<< 3) & -111 ? y
: z
;
96 test_11 (unsigned char x
, int y
, int z
)
99 return ((x
<< 3) & -111) != 0;
103 test_12 (unsigned char x
, int y
, int z
)
106 return ((x
<< 3) & -111) == 0;
110 test_13 (unsigned char* x
, int y
, int z
)
113 return (x
[0] >> 2) & 16 ? y
: z
;
117 test_14 (unsigned char* x
, int y
, int z
)
119 /* 1x tst #64 / 1x bld #6*/
120 return ((x
[0] >> 2) & 16) != 0;
123 test_15 (unsigned char* x
, int y
, int z
)
126 return ((x
[0] >> 2) & 16) == 0;
130 test_16 (unsigned char x
, int y
, int z
)
133 return (x
>> 2) & 16 ? y
: z
;
137 test_17 (unsigned char x
, int y
, int z
)
139 /* 1x tst #64 / 1x bld #6*/
140 return ((x
>> 2) & 16) != 0;
144 test_18 (unsigned char x
, int y
, int z
)
147 return ((x
>> 2) & 16) == 0;
151 test_19 (signed char x
, int y
, int z
)
154 return (x
<< 1) & 0x0F ? y
: z
;
158 test_20 (signed char x
, int y
, int z
)
161 return ((x
<< 1) & 0x0F) != 0;
165 test_21 (signed char x
, int y
, int z
)
168 return ((x
<< 1) & 0x0F) == 0;
172 test_22 (unsigned char* x
, int y
, int z
)
175 return (x
[0] >> 2) ? y
: z
;