[gcc]
[official-gcc.git] / gcc / testsuite / gcc.target / sh / pr49263-3.c
blob0fbed940ddef92865d1c63a68a3dcf58ed781c3c
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 } } } } */
18 int
19 test_00 (unsigned char* x, int y, int z)
21 /* 1x tst #12 */
22 return (x[0] << 4) & 192 ? y : z;
25 int
26 test_01 (unsigned char* x, int y, int z)
28 /* 1x tst #24 */
29 return (x[0] << 3) & 192 ? y : z;
32 int
33 test_02 (unsigned char* x, int y, int z)
35 /* 1x tst #24 */
36 return ((x[0] << 3) & 192) != 0;
39 int
40 test_03 (unsigned char* x, int y, int z)
42 /* 1x tst #24 */
43 return ((x[0] << 3) & 192) == 0;
46 int
47 test_04 (unsigned char x, int y, int z)
49 /* 1x tst #24 */
50 return (x << 3) & 192 ? y : z;
53 int
54 test_05 (unsigned char x, int y, int z)
56 /* 1x tst #24 */
57 return ((x << 3) & 192) != 0;
60 int
61 test_06 (unsigned char x, int y, int z)
63 /* 1x tst #24 */
64 return ((x << 3) & 192) == 0;
67 int
68 test_07 (unsigned char x, int y, int z)
70 /* 1x tst #13 */
71 return (x << 3) & 111 ? y : z;
74 int
75 test_08 (unsigned char x, int y, int z)
77 /* 1x tst #13 */
78 return ((x << 3) & 111) != 0;
81 int
82 test_09 (unsigned char x, int y, int z)
84 /* 1x tst #13 */
85 return ((x << 3) & 111) == 0;
88 int
89 test_10 (unsigned char x, int y, int z)
91 /* 1x tst #242 */
92 return (x << 3) & -111 ? y : z;
95 int
96 test_11 (unsigned char x, int y, int z)
98 /* 1x tst #242 */
99 return ((x << 3) & -111) != 0;
103 test_12 (unsigned char x, int y, int z)
105 /* 1x tst #242 */
106 return ((x << 3) & -111) == 0;
110 test_13 (unsigned char* x, int y, int z)
112 /* 1x tst #64 */
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)
125 /* 1x tst #64 */
126 return ((x[0] >> 2) & 16) == 0;
130 test_16 (unsigned char x, int y, int z)
132 /* 1x tst #64 */
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)
146 /* 1x tst #64 */
147 return ((x >> 2) & 16) == 0;
151 test_19 (signed char x, int y, int z)
153 /* 1x tst #7 */
154 return (x << 1) & 0x0F ? y : z;
158 test_20 (signed char x, int y, int z)
160 /* 1x tst #7 */
161 return ((x << 1) & 0x0F) != 0;
165 test_21 (signed char x, int y, int z)
167 /* 1x tst #7 */
168 return ((x << 1) & 0x0F) == 0;
172 test_22 (unsigned char* x, int y, int z)
174 /* 1x tst #252 */
175 return (x[0] >> 2) ? y : z;