Source file
test/codegen/condmove.go
1
2
3
4
5
6
7 package codegen
8
9 func cmovint(c int) int {
10 x := c + 4
11 if x < 0 {
12 x = 182
13 }
14
15
16
17
18 return x
19 }
20
21 func cmovchan(x, y chan int) chan int {
22 if x != y {
23 x = y
24 }
25
26
27
28
29 return x
30 }
31
32 func cmovuintptr(x, y uintptr) uintptr {
33 if x < y {
34 x = -y
35 }
36
37
38
39
40 return x
41 }
42
43 func cmov32bit(x, y uint32) uint32 {
44 if x < y {
45 x = -y
46 }
47
48
49
50
51 return x
52 }
53
54 func cmov16bit(x, y uint16) uint16 {
55 if x < y {
56 x = -y
57 }
58
59
60
61
62 return x
63 }
64
65
66
67 func cmovfloateq(x, y float64) int {
68 a := 128
69 if x == y {
70 a = 256
71 }
72
73
74
75
76 return a
77 }
78
79 func cmovfloatne(x, y float64) int {
80 a := 128
81 if x != y {
82 a = 256
83 }
84
85
86
87
88 return a
89 }
90
91
92 func frexp(f float64) (frac float64, exp int) {
93 return 1.0, 4
94 }
95
96
97 func ldexp(frac float64, exp int) float64 {
98 return 1.0
99 }
100
101
102 func cmovfloatint2(x, y float64) float64 {
103 yfr, yexp := 4.0, 5
104
105 r := x
106 for r >= y {
107 rfr, rexp := frexp(r)
108 if rfr < yfr {
109 rexp = rexp - 1
110 }
111
112
113
114
115 r = r - ldexp(y, rexp-yexp)
116 }
117 return r
118 }
119
120 func cmovloaded(x [4]int, y int) int {
121 if x[2] != 0 {
122 y = x[2]
123 } else {
124 y = y >> 2
125 }
126
127
128
129
130 return y
131 }
132
133 func cmovuintptr2(x, y uintptr) uintptr {
134 a := x * 2
135 if a == 0 {
136 a = 256
137 }
138
139
140
141
142 return a
143 }
144
145
146 func cmovfloatmove(x, y int) float64 {
147 a := 1.0
148 if x <= y {
149 a = 2.0
150 }
151
152
153
154
155 return a
156 }
157
158
159
160 var gsink int64
161 var gusink uint64
162
163 func cmovinvert1(x, y int64) int64 {
164 if x < gsink {
165 y = -y
166 }
167
168 return y
169 }
170 func cmovinvert2(x, y int64) int64 {
171 if x <= gsink {
172 y = -y
173 }
174
175 return y
176 }
177 func cmovinvert3(x, y int64) int64 {
178 if x == gsink {
179 y = -y
180 }
181
182 return y
183 }
184 func cmovinvert4(x, y int64) int64 {
185 if x != gsink {
186 y = -y
187 }
188
189 return y
190 }
191 func cmovinvert5(x, y uint64) uint64 {
192 if x > gusink {
193 y = -y
194 }
195
196 return y
197 }
198 func cmovinvert6(x, y uint64) uint64 {
199 if x >= gusink {
200 y = -y
201 }
202
203 return y
204 }
205
206 func cmovload(a []int, i int, b bool) int {
207 if b {
208 i++
209 }
210
211
212 return a[i]
213 }
214
215 func cmovstore(a []int, i int, b bool) {
216 if b {
217 i++
218 }
219
220 a[i] = 7
221 }
222
223 var r0, r1, r2, r3, r4, r5 int
224
225 func cmovinc(cond bool, a, b, c int) {
226 var x0, x1 int
227
228 if cond {
229 x0 = a
230 } else {
231 x0 = b + 1
232 }
233
234 r0 = x0
235
236 if cond {
237 x1 = b + 1
238 } else {
239 x1 = a
240 }
241
242 r1 = x1
243
244 if cond {
245 c++
246 }
247
248 r2 = c
249 }
250
251 func cmovinv(cond bool, a, b int) {
252 var x0, x1 int
253
254 if cond {
255 x0 = a
256 } else {
257 x0 = ^b
258 }
259
260 r0 = x0
261
262 if cond {
263 x1 = ^b
264 } else {
265 x1 = a
266 }
267
268 r1 = x1
269 }
270
271 func cmovneg(cond bool, a, b, c int) {
272 var x0, x1 int
273
274 if cond {
275 x0 = a
276 } else {
277 x0 = -b
278 }
279
280 r0 = x0
281
282 if cond {
283 x1 = -b
284 } else {
285 x1 = a
286 }
287
288 r1 = x1
289 }
290
291 func cmovsetm(cond bool, x int) {
292 var x0, x1 int
293
294 if cond {
295 x0 = -1
296 } else {
297 x0 = 0
298 }
299
300 r0 = x0
301
302 if cond {
303 x1 = 0
304 } else {
305 x1 = -1
306 }
307
308 r1 = x1
309 }
310
311 func cmovFcmp0(s, t float64, a, b int) {
312 var x0, x1, x2, x3, x4, x5 int
313
314 if s < t {
315 x0 = a
316 } else {
317 x0 = b + 1
318 }
319
320 r0 = x0
321
322 if s <= t {
323 x1 = a
324 } else {
325 x1 = ^b
326 }
327
328 r1 = x1
329
330 if s > t {
331 x2 = a
332 } else {
333 x2 = -b
334 }
335
336 r2 = x2
337
338 if s >= t {
339 x3 = -1
340 } else {
341 x3 = 0
342 }
343
344 r3 = x3
345
346 if s == t {
347 x4 = a
348 } else {
349 x4 = b + 1
350 }
351
352 r4 = x4
353
354 if s != t {
355 x5 = a
356 } else {
357 x5 = b + 1
358 }
359
360 r5 = x5
361 }
362
363 func cmovFcmp1(s, t float64, a, b int) {
364 var x0, x1, x2, x3, x4, x5 int
365
366 if s < t {
367 x0 = b + 1
368 } else {
369 x0 = a
370 }
371
372 r0 = x0
373
374 if s <= t {
375 x1 = ^b
376 } else {
377 x1 = a
378 }
379
380 r1 = x1
381
382 if s > t {
383 x2 = -b
384 } else {
385 x2 = a
386 }
387
388 r2 = x2
389
390 if s >= t {
391 x3 = 0
392 } else {
393 x3 = -1
394 }
395
396 r3 = x3
397
398 if s == t {
399 x4 = b + 1
400 } else {
401 x4 = a
402 }
403
404 r4 = x4
405
406 if s != t {
407 x5 = b + 1
408 } else {
409 x5 = a
410 }
411
412 r5 = x5
413 }
414
415 func cmovzero1(c bool) int {
416 var x int
417 if c {
418 x = 182
419 }
420
421 return x
422 }
423
424 func cmovzero2(c bool) int {
425 var x int
426 if !c {
427 x = 182
428 }
429
430 return x
431 }
432
433
434
435
436
437 func cmovzeroreg0(a, b int) int {
438 x := 0
439 if a == b {
440 x = a
441 }
442
443 return x
444 }
445
446 func cmovzeroreg1(a, b int) int {
447 x := a
448 if a == b {
449 x = 0
450 }
451
452 return x
453 }
454
View as plain text