1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
/* Check that the compiler properly uses 16-bit encodings where available. */
/* { dg-do compile } */
/* { dg-require-effective-target arm_thumb2_ok } */
/* { dg-options "-Os -fno-builtin -mthumb" } */
int
f (int a, int b)
{
return a + b;
}
/* { dg-final { scan-assembler "add r0, r0, r1" } } */
int
f2 (int a, int b, int c)
{
return b + c;
}
/* { dg-final { scan-assembler "adds r0, r1, r2" } } */
int
g1 (int a)
{
return a + 255;
}
/* { dg-final { scan-assembler "adds r0, r0, #255" } } */
int
g2 (int a)
{
return a + 256;
}
/* { dg-final { scan-assembler "add r0, r0, #256" } } */
int
g3 (int a)
{
return a - 255;
}
/* { dg-final { scan-assembler "subs r0, r0, #255" } } */
int
g4 (int a)
{
return a - 256;
}
/* { dg-final { scan-assembler "sub r0, r0, #256" } } */
int
h1 (int a, int b)
{
return b + 7;
}
/* { dg-final { scan-assembler "adds r0, r1, #7" } } */
int
h2 (int a, int b)
{
return b + 8;
}
/* { dg-final { scan-assembler "add r0, r1, #8" } } */
int
h3 (int a, int b)
{
return b - 7;
}
/* { dg-final { scan-assembler "subs r0, r1, #7" } } */
int
h4 (int a, int b)
{
return b - 8;
}
/* { dg-final { scan-assembler "sub r0, r1, #8" } } */
int
i (int a, int b)
{
return b;
}
/* { dg-final { scan-assembler "mov r0, r1" } } */
int
j1 ()
{
return 255;
}
/* { dg-final { scan-assembler "movs r0, #255" } } */
int
j2 ()
{
return 256;
}
/* { dg-final { scan-assembler "mov r0, #256" } } */
int
k (int a, int b)
{
return b << 15;
}
/* { dg-final { scan-assembler "lsls r0, r1, #15" } } */
int
l1 (int a, int b)
{
return a << b;
}
/* { dg-final { scan-assembler "lsls r0, r0, r1" } } */
int
l2 (int a, int b, int c)
{
return b << c;
}
/* { dg-final { scan-assembler "lsl r0, r1, r2" } } */
int
m (int a, int b)
{
return b >> 15;
}
/* { dg-final { scan-assembler "asrs r0, r1, #15" } } */
int
n1 (int a, int b)
{
return a >> b;
}
/* { dg-final { scan-assembler "asrs r0, r0, r1" } } */
int
n2 (int a, int b, int c)
{
return b >> c;
}
/* { dg-final { scan-assembler "asr r0, r1, r2" } } */
unsigned int
o (unsigned int a, unsigned int b)
{
return b >> 15;
}
/* { dg-final { scan-assembler "lsrs r0, r1, #15" } } */
unsigned int
p1 (unsigned int a, unsigned int b)
{
return a >> b;
}
/* { dg-final { scan-assembler "lsrs r0, r0, r1" } } */
unsigned int
p2 (unsigned int a, unsigned int b, unsigned int c)
{
return b >> c;
}
/* { dg-final { scan-assembler "lsr r0, r1, r2" } } */
int
q (int a, int b)
{
return b * a;
}
/* { dg-final { scan-assembler "muls r0, r1, r0" } } */
int
r (int a, int b)
{
return ~b;
}
/* { dg-final { scan-assembler "mvns r0, r1" } } */
int
s (int a, int b)
{
return -b;
}
/* { dg-final { scan-assembler "negs r0, r1" } } */
|