summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/atomic-minmax-i6432.ll
blob: 565ebb59068886086e3c126096b08166698be4a2 (plain)
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mattr=+cmov,cx16 -mtriple=i386-pc-linux -verify-machineinstrs < %s | FileCheck %s -check-prefix=LINUX
; RUN: llc -mattr=cx16 -mtriple=i386-macosx -relocation-model=pic -verify-machineinstrs < %s | FileCheck %s -check-prefix=PIC

@sc64 = external global i64

define i64 @atomic_max_i64() nounwind {
; LINUX-LABEL: atomic_max_i64:
; LINUX:       # BB#0: # %entry
; LINUX-NEXT:    pushl %ebx
; LINUX-NEXT:    pushl %esi
; LINUX-NEXT:    movl sc64+4, %edx
; LINUX-NEXT:    movl sc64, %eax
; LINUX-NEXT:    movl $4, %esi
; LINUX-NEXT:    .p2align 4, 0x90
; LINUX-NEXT:  .LBB0_1: # %atomicrmw.start
; LINUX-NEXT:    # =>This Inner Loop Header: Depth=1
; LINUX-NEXT:    xorl %ecx, %ecx
; LINUX-NEXT:    cmpl %eax, %esi
; LINUX-NEXT:    sbbl %edx, %ecx
; LINUX-NEXT:    setl %cl
; LINUX-NEXT:    andb $1, %cl
; LINUX-NEXT:    movl %eax, %ebx
; LINUX-NEXT:    jne .LBB0_3
; LINUX-NEXT:  # BB#2: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB0_1 Depth=1
; LINUX-NEXT:    movl $5, %ebx
; LINUX-NEXT:  .LBB0_3: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB0_1 Depth=1
; LINUX-NEXT:    testb %cl, %cl
; LINUX-NEXT:    movl %edx, %ecx
; LINUX-NEXT:    jne .LBB0_5
; LINUX-NEXT:  # BB#4: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB0_1 Depth=1
; LINUX-NEXT:    xorl %ecx, %ecx
; LINUX-NEXT:  .LBB0_5: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB0_1 Depth=1
; LINUX-NEXT:    lock cmpxchg8b sc64
; LINUX-NEXT:    jne .LBB0_1
; LINUX-NEXT:  # BB#6: # %atomicrmw.end
; LINUX-NEXT:    popl %esi
; LINUX-NEXT:    popl %ebx
; LINUX-NEXT:    retl
;
; PIC-LABEL: atomic_max_i64:
; PIC:       ## BB#0: ## %entry
; PIC-NEXT:    pushl %ebx
; PIC-NEXT:    pushl %edi
; PIC-NEXT:    pushl %esi
; PIC-NEXT:    calll L0$pb
; PIC-NEXT:  L0$pb:
; PIC-NEXT:    popl %eax
; PIC-NEXT:    movl L_sc64$non_lazy_ptr-L0$pb(%eax), %esi
; PIC-NEXT:    movl (%esi), %eax
; PIC-NEXT:    movl 4(%esi), %edx
; PIC-NEXT:    movl $4, %edi
; PIC-NEXT:    .p2align 4, 0x90
; PIC-NEXT:  LBB0_1: ## %atomicrmw.start
; PIC-NEXT:    ## =>This Inner Loop Header: Depth=1
; PIC-NEXT:    xorl %ecx, %ecx
; PIC-NEXT:    cmpl %eax, %edi
; PIC-NEXT:    sbbl %edx, %ecx
; PIC-NEXT:    setl %cl
; PIC-NEXT:    andb $1, %cl
; PIC-NEXT:    movl %eax, %ebx
; PIC-NEXT:    jne LBB0_3
; PIC-NEXT:  ## BB#2: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB0_1 Depth=1
; PIC-NEXT:    movl $5, %ebx
; PIC-NEXT:  LBB0_3: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB0_1 Depth=1
; PIC-NEXT:    testb %cl, %cl
; PIC-NEXT:    movl %edx, %ecx
; PIC-NEXT:    jne LBB0_5
; PIC-NEXT:  ## BB#4: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB0_1 Depth=1
; PIC-NEXT:    xorl %ecx, %ecx
; PIC-NEXT:  LBB0_5: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB0_1 Depth=1
; PIC-NEXT:    lock cmpxchg8b (%esi)
; PIC-NEXT:    jne LBB0_1
; PIC-NEXT:  ## BB#6: ## %atomicrmw.end
; PIC-NEXT:    popl %esi
; PIC-NEXT:    popl %edi
; PIC-NEXT:    popl %ebx
; PIC-NEXT:    retl
; PIC-NEXT:    ## -- End function
entry:
  %max = atomicrmw max i64* @sc64, i64 5 acquire
  ret i64 %max
}

define i64 @atomic_min_i64() nounwind {
; LINUX-LABEL: atomic_min_i64:
; LINUX:       # BB#0: # %entry
; LINUX-NEXT:    pushl %ebx
; LINUX-NEXT:    movl sc64+4, %edx
; LINUX-NEXT:    movl sc64, %eax
; LINUX-NEXT:    .p2align 4, 0x90
; LINUX-NEXT:  .LBB1_1: # %atomicrmw.start
; LINUX-NEXT:    # =>This Inner Loop Header: Depth=1
; LINUX-NEXT:    cmpl $7, %eax
; LINUX-NEXT:    movl %edx, %ecx
; LINUX-NEXT:    sbbl $0, %ecx
; LINUX-NEXT:    setl %cl
; LINUX-NEXT:    andb $1, %cl
; LINUX-NEXT:    movl %eax, %ebx
; LINUX-NEXT:    jne .LBB1_3
; LINUX-NEXT:  # BB#2: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB1_1 Depth=1
; LINUX-NEXT:    movl $6, %ebx
; LINUX-NEXT:  .LBB1_3: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB1_1 Depth=1
; LINUX-NEXT:    testb %cl, %cl
; LINUX-NEXT:    movl %edx, %ecx
; LINUX-NEXT:    jne .LBB1_5
; LINUX-NEXT:  # BB#4: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB1_1 Depth=1
; LINUX-NEXT:    xorl %ecx, %ecx
; LINUX-NEXT:  .LBB1_5: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB1_1 Depth=1
; LINUX-NEXT:    lock cmpxchg8b sc64
; LINUX-NEXT:    jne .LBB1_1
; LINUX-NEXT:  # BB#6: # %atomicrmw.end
; LINUX-NEXT:    popl %ebx
; LINUX-NEXT:    retl
;
; PIC-LABEL: atomic_min_i64:
; PIC:       ## BB#0: ## %entry
; PIC-NEXT:    pushl %ebx
; PIC-NEXT:    pushl %esi
; PIC-NEXT:    calll L1$pb
; PIC-NEXT:  L1$pb:
; PIC-NEXT:    popl %eax
; PIC-NEXT:    movl L_sc64$non_lazy_ptr-L1$pb(%eax), %esi
; PIC-NEXT:    movl (%esi), %eax
; PIC-NEXT:    movl 4(%esi), %edx
; PIC-NEXT:    .p2align 4, 0x90
; PIC-NEXT:  LBB1_1: ## %atomicrmw.start
; PIC-NEXT:    ## =>This Inner Loop Header: Depth=1
; PIC-NEXT:    cmpl $7, %eax
; PIC-NEXT:    movl %edx, %ecx
; PIC-NEXT:    sbbl $0, %ecx
; PIC-NEXT:    setl %cl
; PIC-NEXT:    andb $1, %cl
; PIC-NEXT:    movl %eax, %ebx
; PIC-NEXT:    jne LBB1_3
; PIC-NEXT:  ## BB#2: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB1_1 Depth=1
; PIC-NEXT:    movl $6, %ebx
; PIC-NEXT:  LBB1_3: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB1_1 Depth=1
; PIC-NEXT:    testb %cl, %cl
; PIC-NEXT:    movl %edx, %ecx
; PIC-NEXT:    jne LBB1_5
; PIC-NEXT:  ## BB#4: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB1_1 Depth=1
; PIC-NEXT:    xorl %ecx, %ecx
; PIC-NEXT:  LBB1_5: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB1_1 Depth=1
; PIC-NEXT:    lock cmpxchg8b (%esi)
; PIC-NEXT:    jne LBB1_1
; PIC-NEXT:  ## BB#6: ## %atomicrmw.end
; PIC-NEXT:    popl %esi
; PIC-NEXT:    popl %ebx
; PIC-NEXT:    retl
; PIC-NEXT:    ## -- End function
entry:
  %min = atomicrmw min i64* @sc64, i64 6 acquire
  ret i64 %min
}

define i64 @atomic_umax_i64() nounwind {
; LINUX-LABEL: atomic_umax_i64:
; LINUX:       # BB#0: # %entry
; LINUX-NEXT:    pushl %ebx
; LINUX-NEXT:    pushl %esi
; LINUX-NEXT:    movl sc64+4, %edx
; LINUX-NEXT:    movl sc64, %eax
; LINUX-NEXT:    movl $7, %esi
; LINUX-NEXT:    .p2align 4, 0x90
; LINUX-NEXT:  .LBB2_1: # %atomicrmw.start
; LINUX-NEXT:    # =>This Inner Loop Header: Depth=1
; LINUX-NEXT:    xorl %ecx, %ecx
; LINUX-NEXT:    cmpl %eax, %esi
; LINUX-NEXT:    sbbl %edx, %ecx
; LINUX-NEXT:    setb %cl
; LINUX-NEXT:    andb $1, %cl
; LINUX-NEXT:    movl %eax, %ebx
; LINUX-NEXT:    jne .LBB2_3
; LINUX-NEXT:  # BB#2: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB2_1 Depth=1
; LINUX-NEXT:    movl $7, %ebx
; LINUX-NEXT:  .LBB2_3: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB2_1 Depth=1
; LINUX-NEXT:    testb %cl, %cl
; LINUX-NEXT:    movl %edx, %ecx
; LINUX-NEXT:    jne .LBB2_5
; LINUX-NEXT:  # BB#4: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB2_1 Depth=1
; LINUX-NEXT:    xorl %ecx, %ecx
; LINUX-NEXT:  .LBB2_5: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB2_1 Depth=1
; LINUX-NEXT:    lock cmpxchg8b sc64
; LINUX-NEXT:    jne .LBB2_1
; LINUX-NEXT:  # BB#6: # %atomicrmw.end
; LINUX-NEXT:    popl %esi
; LINUX-NEXT:    popl %ebx
; LINUX-NEXT:    retl
;
; PIC-LABEL: atomic_umax_i64:
; PIC:       ## BB#0: ## %entry
; PIC-NEXT:    pushl %ebx
; PIC-NEXT:    pushl %edi
; PIC-NEXT:    pushl %esi
; PIC-NEXT:    calll L2$pb
; PIC-NEXT:  L2$pb:
; PIC-NEXT:    popl %eax
; PIC-NEXT:    movl L_sc64$non_lazy_ptr-L2$pb(%eax), %esi
; PIC-NEXT:    movl (%esi), %eax
; PIC-NEXT:    movl 4(%esi), %edx
; PIC-NEXT:    movl $7, %edi
; PIC-NEXT:    .p2align 4, 0x90
; PIC-NEXT:  LBB2_1: ## %atomicrmw.start
; PIC-NEXT:    ## =>This Inner Loop Header: Depth=1
; PIC-NEXT:    xorl %ecx, %ecx
; PIC-NEXT:    cmpl %eax, %edi
; PIC-NEXT:    sbbl %edx, %ecx
; PIC-NEXT:    setb %cl
; PIC-NEXT:    andb $1, %cl
; PIC-NEXT:    movl %eax, %ebx
; PIC-NEXT:    jne LBB2_3
; PIC-NEXT:  ## BB#2: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB2_1 Depth=1
; PIC-NEXT:    movl $7, %ebx
; PIC-NEXT:  LBB2_3: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB2_1 Depth=1
; PIC-NEXT:    testb %cl, %cl
; PIC-NEXT:    movl %edx, %ecx
; PIC-NEXT:    jne LBB2_5
; PIC-NEXT:  ## BB#4: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB2_1 Depth=1
; PIC-NEXT:    xorl %ecx, %ecx
; PIC-NEXT:  LBB2_5: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB2_1 Depth=1
; PIC-NEXT:    lock cmpxchg8b (%esi)
; PIC-NEXT:    jne LBB2_1
; PIC-NEXT:  ## BB#6: ## %atomicrmw.end
; PIC-NEXT:    popl %esi
; PIC-NEXT:    popl %edi
; PIC-NEXT:    popl %ebx
; PIC-NEXT:    retl
; PIC-NEXT:    ## -- End function
entry:
  %umax = atomicrmw umax i64* @sc64, i64 7 acquire
  ret i64 %umax
}

define i64 @atomic_umin_i64() nounwind {
; LINUX-LABEL: atomic_umin_i64:
; LINUX:       # BB#0: # %entry
; LINUX-NEXT:    pushl %ebx
; LINUX-NEXT:    movl sc64+4, %edx
; LINUX-NEXT:    movl sc64, %eax
; LINUX-NEXT:    .p2align 4, 0x90
; LINUX-NEXT:  .LBB3_1: # %atomicrmw.start
; LINUX-NEXT:    # =>This Inner Loop Header: Depth=1
; LINUX-NEXT:    cmpl $9, %eax
; LINUX-NEXT:    movl %edx, %ecx
; LINUX-NEXT:    sbbl $0, %ecx
; LINUX-NEXT:    setb %cl
; LINUX-NEXT:    andb $1, %cl
; LINUX-NEXT:    movl %eax, %ebx
; LINUX-NEXT:    jne .LBB3_3
; LINUX-NEXT:  # BB#2: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB3_1 Depth=1
; LINUX-NEXT:    movl $8, %ebx
; LINUX-NEXT:  .LBB3_3: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB3_1 Depth=1
; LINUX-NEXT:    testb %cl, %cl
; LINUX-NEXT:    movl %edx, %ecx
; LINUX-NEXT:    jne .LBB3_5
; LINUX-NEXT:  # BB#4: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB3_1 Depth=1
; LINUX-NEXT:    xorl %ecx, %ecx
; LINUX-NEXT:  .LBB3_5: # %atomicrmw.start
; LINUX-NEXT:    # in Loop: Header=BB3_1 Depth=1
; LINUX-NEXT:    lock cmpxchg8b sc64
; LINUX-NEXT:    jne .LBB3_1
; LINUX-NEXT:  # BB#6: # %atomicrmw.end
; LINUX-NEXT:    popl %ebx
; LINUX-NEXT:    retl
;
; PIC-LABEL: atomic_umin_i64:
; PIC:       ## BB#0: ## %entry
; PIC-NEXT:    pushl %ebx
; PIC-NEXT:    pushl %esi
; PIC-NEXT:    calll L3$pb
; PIC-NEXT:  L3$pb:
; PIC-NEXT:    popl %eax
; PIC-NEXT:    movl L_sc64$non_lazy_ptr-L3$pb(%eax), %esi
; PIC-NEXT:    movl (%esi), %eax
; PIC-NEXT:    movl 4(%esi), %edx
; PIC-NEXT:    .p2align 4, 0x90
; PIC-NEXT:  LBB3_1: ## %atomicrmw.start
; PIC-NEXT:    ## =>This Inner Loop Header: Depth=1
; PIC-NEXT:    cmpl $9, %eax
; PIC-NEXT:    movl %edx, %ecx
; PIC-NEXT:    sbbl $0, %ecx
; PIC-NEXT:    setb %cl
; PIC-NEXT:    andb $1, %cl
; PIC-NEXT:    movl %eax, %ebx
; PIC-NEXT:    jne LBB3_3
; PIC-NEXT:  ## BB#2: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB3_1 Depth=1
; PIC-NEXT:    movl $8, %ebx
; PIC-NEXT:  LBB3_3: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB3_1 Depth=1
; PIC-NEXT:    testb %cl, %cl
; PIC-NEXT:    movl %edx, %ecx
; PIC-NEXT:    jne LBB3_5
; PIC-NEXT:  ## BB#4: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB3_1 Depth=1
; PIC-NEXT:    xorl %ecx, %ecx
; PIC-NEXT:  LBB3_5: ## %atomicrmw.start
; PIC-NEXT:    ## in Loop: Header=BB3_1 Depth=1
; PIC-NEXT:    lock cmpxchg8b (%esi)
; PIC-NEXT:    jne LBB3_1
; PIC-NEXT:  ## BB#6: ## %atomicrmw.end
; PIC-NEXT:    popl %esi
; PIC-NEXT:    popl %ebx
; PIC-NEXT:    retl
; PIC-NEXT:    ## -- End function
entry:
  %umin = atomicrmw umin i64* @sc64, i64 8 acquire
  ret i64 %umin
}

@id = internal global i64 0, align 8

define void @tf_bug(i8* %ptr) nounwind {
; LINUX-LABEL: tf_bug:
; LINUX:       # BB#0: # %entry
; LINUX-NEXT:    pushl %ebx
; LINUX-NEXT:    pushl %esi
; LINUX-NEXT:    movl {{[0-9]+}}(%esp), %esi
; LINUX-NEXT:    movl id+4, %edx
; LINUX-NEXT:    movl id, %eax
; LINUX-NEXT:    .p2align 4, 0x90
; LINUX-NEXT:  .LBB4_1: # %atomicrmw.start
; LINUX-NEXT:    # =>This Inner Loop Header: Depth=1
; LINUX-NEXT:    movl %eax, %ebx
; LINUX-NEXT:    addl $1, %ebx
; LINUX-NEXT:    movl %edx, %ecx
; LINUX-NEXT:    adcl $0, %ecx
; LINUX-NEXT:    lock cmpxchg8b id
; LINUX-NEXT:    jne .LBB4_1
; LINUX-NEXT:  # BB#2: # %atomicrmw.end
; LINUX-NEXT:    addl $1, %eax
; LINUX-NEXT:    adcl $0, %edx
; LINUX-NEXT:    movl %eax, (%esi)
; LINUX-NEXT:    movl %edx, 4(%esi)
; LINUX-NEXT:    popl %esi
; LINUX-NEXT:    popl %ebx
; LINUX-NEXT:    retl
;
; PIC-LABEL: tf_bug:
; PIC:       ## BB#0: ## %entry
; PIC-NEXT:    pushl %ebx
; PIC-NEXT:    pushl %edi
; PIC-NEXT:    pushl %esi
; PIC-NEXT:    calll L4$pb
; PIC-NEXT:  L4$pb:
; PIC-NEXT:    popl %edi
; PIC-NEXT:    movl {{[0-9]+}}(%esp), %esi
; PIC-NEXT:    movl (_id-L4$pb)+4(%edi), %edx
; PIC-NEXT:    movl _id-L4$pb(%edi), %eax
; PIC-NEXT:    .p2align 4, 0x90
; PIC-NEXT:  LBB4_1: ## %atomicrmw.start
; PIC-NEXT:    ## =>This Inner Loop Header: Depth=1
; PIC-NEXT:    movl %eax, %ebx
; PIC-NEXT:    addl $1, %ebx
; PIC-NEXT:    movl %edx, %ecx
; PIC-NEXT:    adcl $0, %ecx
; PIC-NEXT:    lock cmpxchg8b _id-L4$pb(%edi)
; PIC-NEXT:    jne LBB4_1
; PIC-NEXT:  ## BB#2: ## %atomicrmw.end
; PIC-NEXT:    addl $1, %eax
; PIC-NEXT:    adcl $0, %edx
; PIC-NEXT:    movl %eax, (%esi)
; PIC-NEXT:    movl %edx, 4(%esi)
; PIC-NEXT:    popl %esi
; PIC-NEXT:    popl %edi
; PIC-NEXT:    popl %ebx
; PIC-NEXT:    retl
; PIC-NEXT:    ## -- End function
; PIC-NEXT:  .zerofill __DATA,__bss,_id,8,3 ## @id
entry:
  %tmp1 = atomicrmw add i64* @id, i64 1 seq_cst
  %tmp2 = add i64 %tmp1, 1
  %tmp3 = bitcast i8* %ptr to i64*
  store i64 %tmp2, i64* %tmp3, align 4
  ret void
}
OpenPOWER on IntegriCloud