Stackmap shadows should consider call returns a branch target.
[oota-llvm.git] / test / CodeGen / Mips / atomic.ll
1 ; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32   < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS32-ANY -check-prefix=NO-SEB-SEH  -check-prefix=CHECK-EL
2 ; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32r2 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS32-ANY -check-prefix=HAS-SEB-SEH -check-prefix=CHECK-EL
3 ; RUN: llc -march=mipsel --disable-machine-licm -mcpu=mips32r6 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS32-ANY -check-prefix=HAS-SEB-SEH -check-prefix=CHECK-EL
4 ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips4    < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS64-ANY -check-prefix=NO-SEB-SEH  -check-prefix=CHECK-EL
5 ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64   < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS64-ANY -check-prefix=NO-SEB-SEH  -check-prefix=CHECK-EL
6 ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64r2 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS64-ANY -check-prefix=HAS-SEB-SEH -check-prefix=CHECK-EL
7 ; RUN: llc -march=mips64el --disable-machine-licm -mcpu=mips64r6 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS64-ANY -check-prefix=HAS-SEB-SEH -check-prefix=CHECK-EL
8
9 ; Keep one big-endian check so that we don't reduce testing, but don't add more
10 ; since endianness doesn't affect the body of the atomic operations.
11 ; RUN: llc -march=mips   --disable-machine-licm -mcpu=mips32 < %s | FileCheck %s -check-prefix=ALL -check-prefix=MIPS32-ANY -check-prefix=NO-SEB-SEH -check-prefix=CHECK-EB
12
13 @x = common global i32 0, align 4
14
15 define i32 @AtomicLoadAdd32(i32 %incr) nounwind {
16 entry:
17   %0 = atomicrmw add i32* @x, i32 %incr monotonic
18   ret i32 %0
19
20 ; ALL-LABEL: AtomicLoadAdd32:
21
22 ; MIPS32-ANY:    lw      $[[R0:[0-9]+]], %got(x)
23 ; MIPS64-ANY:    ld      $[[R0:[0-9]+]], %got_disp(x)(
24
25 ; ALL:       $[[BB0:[A-Z_0-9]+]]:
26 ; ALL:           ll      $[[R1:[0-9]+]], 0($[[R0]])
27 ; ALL:           addu    $[[R2:[0-9]+]], $[[R1]], $4
28 ; ALL:           sc      $[[R2]], 0($[[R0]])
29 ; ALL:           beqz    $[[R2]], $[[BB0]]
30 }
31
32 define i32 @AtomicLoadNand32(i32 %incr) nounwind {
33 entry:
34   %0 = atomicrmw nand i32* @x, i32 %incr monotonic
35   ret i32 %0
36
37 ; ALL-LABEL: AtomicLoadNand32:
38
39 ; MIPS32-ANY:    lw      $[[R0:[0-9]+]], %got(x)
40 ; MIPS64-ANY:    ld      $[[R0:[0-9]+]], %got_disp(x)(
41
42 ; ALL:       $[[BB0:[A-Z_0-9]+]]:
43 ; ALL:           ll      $[[R1:[0-9]+]], 0($[[R0]])
44 ; ALL:           and     $[[R3:[0-9]+]], $[[R1]], $4
45 ; ALL:           nor     $[[R2:[0-9]+]], $zero, $[[R3]]
46 ; ALL:           sc      $[[R2]], 0($[[R0]])
47 ; ALL:           beqz    $[[R2]], $[[BB0]]
48 }
49
50 define i32 @AtomicSwap32(i32 %newval) nounwind {
51 entry:
52   %newval.addr = alloca i32, align 4
53   store i32 %newval, i32* %newval.addr, align 4
54   %tmp = load i32* %newval.addr, align 4
55   %0 = atomicrmw xchg i32* @x, i32 %tmp monotonic
56   ret i32 %0
57
58 ; ALL-LABEL: AtomicSwap32:
59
60 ; MIPS32-ANY:    lw      $[[R0:[0-9]+]], %got(x)
61 ; MIPS64-ANY:    ld      $[[R0:[0-9]+]], %got_disp(x)
62
63 ; ALL:       $[[BB0:[A-Z_0-9]+]]:
64 ; ALL:           ll      ${{[0-9]+}}, 0($[[R0]])
65 ; ALL:           sc      $[[R2:[0-9]+]], 0($[[R0]])
66 ; ALL:           beqz    $[[R2]], $[[BB0]]
67 }
68
69 define i32 @AtomicCmpSwap32(i32 %oldval, i32 %newval) nounwind {
70 entry:
71   %newval.addr = alloca i32, align 4
72   store i32 %newval, i32* %newval.addr, align 4
73   %tmp = load i32* %newval.addr, align 4
74   %0 = cmpxchg i32* @x, i32 %oldval, i32 %tmp monotonic monotonic
75   %1 = extractvalue { i32, i1 } %0, 0
76   ret i32 %1
77
78 ; ALL-LABEL: AtomicCmpSwap32:
79
80 ; MIPS32-ANY:    lw      $[[R0:[0-9]+]], %got(x)
81 ; MIPS64-ANY:    ld      $[[R0:[0-9]+]], %got_disp(x)(
82
83 ; ALL:       $[[BB0:[A-Z_0-9]+]]:
84 ; ALL:           ll      $2, 0($[[R0]])
85 ; ALL:           bne     $2, $4, $[[BB1:[A-Z_0-9]+]]
86 ; ALL:           sc      $[[R2:[0-9]+]], 0($[[R0]])
87 ; ALL:           beqz    $[[R2]], $[[BB0]]
88 ; ALL:       $[[BB1]]:
89 }
90
91
92
93 @y = common global i8 0, align 1
94
95 define signext i8 @AtomicLoadAdd8(i8 signext %incr) nounwind {
96 entry:
97   %0 = atomicrmw add i8* @y, i8 %incr monotonic
98   ret i8 %0
99
100 ; ALL-LABEL: AtomicLoadAdd8:
101
102 ; MIPS32-ANY:    lw      $[[R0:[0-9]+]], %got(y)
103 ; MIPS64-ANY:    ld      $[[R0:[0-9]+]], %got_disp(y)(
104
105 ; ALL:           addiu   $[[R1:[0-9]+]], $zero, -4
106 ; ALL:           and     $[[R2:[0-9]+]], $[[R0]], $[[R1]]
107 ; ALL:           andi    $[[R3:[0-9]+]], $[[R0]], 3
108 ; CHECK-EB:      xori    $[[R4:[0-9]+]], $[[R3]], 3
109 ; CHECK-EB:      sll     $[[R5:[0-9]+]], $[[R4]], 3
110 ; CHECK-EL:      sll     $[[R5:[0-9]+]], $[[R3]], 3
111 ; ALL:           ori     $[[R6:[0-9]+]], $zero, 255
112 ; ALL:           sllv    $[[R7:[0-9]+]], $[[R6]], $[[R5]]
113 ; ALL:           nor     $[[R8:[0-9]+]], $zero, $[[R7]]
114 ; ALL:           sllv    $[[R9:[0-9]+]], $4, $[[R5]]
115
116 ; ALL:       $[[BB0:[A-Z_0-9]+]]:
117 ; ALL:           ll      $[[R10:[0-9]+]], 0($[[R2]])
118 ; ALL:           addu    $[[R11:[0-9]+]], $[[R10]], $[[R9]]
119 ; ALL:           and     $[[R12:[0-9]+]], $[[R11]], $[[R7]]
120 ; ALL:           and     $[[R13:[0-9]+]], $[[R10]], $[[R8]]
121 ; ALL:           or      $[[R14:[0-9]+]], $[[R13]], $[[R12]]
122 ; ALL:           sc      $[[R14]], 0($[[R2]])
123 ; ALL:           beqz    $[[R14]], $[[BB0]]
124
125 ; ALL:           and     $[[R15:[0-9]+]], $[[R10]], $[[R7]]
126 ; ALL:           srlv    $[[R16:[0-9]+]], $[[R15]], $[[R5]]
127
128 ; NO-SEB-SEH:    sll     $[[R17:[0-9]+]], $[[R16]], 24
129 ; NO-SEB-SEH:    sra     $2, $[[R17]], 24
130
131 ; HAS-SEB-SEH:   seb     $2, $[[R16]]
132 }
133
134 define signext i8 @AtomicLoadSub8(i8 signext %incr) nounwind {
135 entry:
136   %0 = atomicrmw sub i8* @y, i8 %incr monotonic
137   ret i8 %0
138
139 ; ALL-LABEL: AtomicLoadSub8:
140
141 ; MIPS32-ANY: lw      $[[R0:[0-9]+]], %got(y)
142 ; MIPS64-ANY: ld      $[[R0:[0-9]+]], %got_disp(y)(
143
144 ; ALL:        addiu   $[[R1:[0-9]+]], $zero, -4
145 ; ALL:        and     $[[R2:[0-9]+]], $[[R0]], $[[R1]]
146 ; ALL:        andi    $[[R3:[0-9]+]], $[[R0]], 3
147 ; CHECK-EL:   sll     $[[R5:[0-9]+]], $[[R3]], 3
148 ; CHECK-EB:   xori    $[[R4:[0-9]+]], $[[R3]], 3
149 ; CHECK-EB:   sll     $[[R5:[0-9]+]], $[[R4]], 3
150 ; ALL:        ori     $[[R6:[0-9]+]], $zero, 255
151 ; ALL:        sllv    $[[R7:[0-9]+]], $[[R6]], $[[R5]]
152 ; ALL:        nor     $[[R8:[0-9]+]], $zero, $[[R7]]
153 ; ALL:        sllv    $[[R9:[0-9]+]], $4, $[[R5]]
154
155 ; ALL:    $[[BB0:[A-Z_0-9]+]]:
156 ; ALL:        ll      $[[R10:[0-9]+]], 0($[[R2]])
157 ; ALL:        subu    $[[R11:[0-9]+]], $[[R10]], $[[R9]]
158 ; ALL:        and     $[[R12:[0-9]+]], $[[R11]], $[[R7]]
159 ; ALL:        and     $[[R13:[0-9]+]], $[[R10]], $[[R8]]
160 ; ALL:        or      $[[R14:[0-9]+]], $[[R13]], $[[R12]]
161 ; ALL:        sc      $[[R14]], 0($[[R2]])
162 ; ALL:        beqz    $[[R14]], $[[BB0]]
163
164 ; ALL:        and     $[[R15:[0-9]+]], $[[R10]], $[[R7]]
165 ; ALL:        srlv    $[[R16:[0-9]+]], $[[R15]], $[[R5]]
166
167 ; NO-SEB-SEH: sll     $[[R17:[0-9]+]], $[[R16]], 24
168 ; NO-SEB-SEH: sra     $2, $[[R17]], 24
169
170 ; HAS-SEB-SEH:seb     $2, $[[R16]]
171 }
172
173 define signext i8 @AtomicLoadNand8(i8 signext %incr) nounwind {
174 entry:
175   %0 = atomicrmw nand i8* @y, i8 %incr monotonic
176   ret i8 %0
177
178 ; ALL-LABEL: AtomicLoadNand8:
179
180 ; MIPS32-ANY:    lw      $[[R0:[0-9]+]], %got(y)
181 ; MIPS64-ANY:    ld      $[[R0:[0-9]+]], %got_disp(y)(
182
183 ; ALL:           addiu   $[[R1:[0-9]+]], $zero, -4
184 ; ALL:           and     $[[R2:[0-9]+]], $[[R0]], $[[R1]]
185 ; ALL:           andi    $[[R3:[0-9]+]], $[[R0]], 3
186 ; CHECK-EL:      sll     $[[R5:[0-9]+]], $[[R3]], 3
187 ; CHECK-EB:      xori    $[[R4:[0-9]+]], $[[R3]], 3
188 ; CHECK-EB:      sll     $[[R5:[0-9]+]], $[[R4]], 3
189 ; ALL:           ori     $[[R6:[0-9]+]], $zero, 255
190 ; ALL:           sllv    $[[R7:[0-9]+]], $[[R6]], $[[R5]]
191 ; ALL:           nor     $[[R8:[0-9]+]], $zero, $[[R7]]
192 ; ALL:           sllv    $[[R9:[0-9]+]], $4, $[[R5]]
193
194 ; ALL:       $[[BB0:[A-Z_0-9]+]]:
195 ; ALL:           ll      $[[R10:[0-9]+]], 0($[[R2]])
196 ; ALL:           and     $[[R18:[0-9]+]], $[[R10]], $[[R9]]
197 ; ALL:           nor     $[[R11:[0-9]+]], $zero, $[[R18]]
198 ; ALL:           and     $[[R12:[0-9]+]], $[[R11]], $[[R7]]
199 ; ALL:           and     $[[R13:[0-9]+]], $[[R10]], $[[R8]]
200 ; ALL:           or      $[[R14:[0-9]+]], $[[R13]], $[[R12]]
201 ; ALL:           sc      $[[R14]], 0($[[R2]])
202 ; ALL:           beqz    $[[R14]], $[[BB0]]
203
204 ; ALL:           and     $[[R15:[0-9]+]], $[[R10]], $[[R7]]
205 ; ALL:           srlv    $[[R16:[0-9]+]], $[[R15]], $[[R5]]
206
207 ; NO-SEB-SEH:    sll     $[[R17:[0-9]+]], $[[R16]], 24
208 ; NO-SEB-SEH:    sra     $2, $[[R17]], 24
209
210 ; HAS-SEB-SEH:   seb     $2, $[[R16]]
211 }
212
213 define signext i8 @AtomicSwap8(i8 signext %newval) nounwind {
214 entry:
215   %0 = atomicrmw xchg i8* @y, i8 %newval monotonic
216   ret i8 %0
217
218 ; ALL-LABEL: AtomicSwap8:
219
220 ; MIPS32-ANY:    lw      $[[R0:[0-9]+]], %got(y)
221 ; MIPS64-ANY:    ld      $[[R0:[0-9]+]], %got_disp(y)(
222
223 ; ALL:           addiu   $[[R1:[0-9]+]], $zero, -4
224 ; ALL:           and     $[[R2:[0-9]+]], $[[R0]], $[[R1]]
225 ; ALL:           andi    $[[R3:[0-9]+]], $[[R0]], 3
226 ; CHECK-EL:      sll     $[[R5:[0-9]+]], $[[R3]], 3
227 ; CHECK-EB:      xori    $[[R4:[0-9]+]], $[[R3]], 3
228 ; CHECK-EB:      sll     $[[R5:[0-9]+]], $[[R4]], 3
229 ; ALL:           ori     $[[R6:[0-9]+]], $zero, 255
230 ; ALL:           sllv    $[[R7:[0-9]+]], $[[R6]], $[[R5]]
231 ; ALL:           nor     $[[R8:[0-9]+]], $zero, $[[R7]]
232 ; ALL:           sllv    $[[R9:[0-9]+]], $4, $[[R5]]
233
234 ; ALL:       $[[BB0:[A-Z_0-9]+]]:
235 ; ALL:           ll      $[[R10:[0-9]+]], 0($[[R2]])
236 ; ALL:           and     $[[R18:[0-9]+]], $[[R9]], $[[R7]]
237 ; ALL:           and     $[[R13:[0-9]+]], $[[R10]], $[[R8]]
238 ; ALL:           or      $[[R14:[0-9]+]], $[[R13]], $[[R18]]
239 ; ALL:           sc      $[[R14]], 0($[[R2]])
240 ; ALL:           beqz    $[[R14]], $[[BB0]]
241
242 ; ALL:           and     $[[R15:[0-9]+]], $[[R10]], $[[R7]]
243 ; ALL:           srlv    $[[R16:[0-9]+]], $[[R15]], $[[R5]]
244
245 ; NO-SEB-SEH:    sll     $[[R17:[0-9]+]], $[[R16]], 24
246 ; NO-SEB-SEH:    sra     $2, $[[R17]], 24
247
248 ; HAS-SEB-SEH:   seb     $2, $[[R16]]
249
250 }
251
252 define signext i8 @AtomicCmpSwap8(i8 signext %oldval, i8 signext %newval) nounwind {
253 entry:
254   %pair0 = cmpxchg i8* @y, i8 %oldval, i8 %newval monotonic monotonic
255   %0 = extractvalue { i8, i1 } %pair0, 0
256   ret i8 %0
257
258 ; ALL-LABEL: AtomicCmpSwap8:
259
260 ; MIPS32-ANY:    lw      $[[R0:[0-9]+]], %got(y)
261 ; MIPS64-ANY:    ld      $[[R0:[0-9]+]], %got_disp(y)(
262
263 ; ALL:           addiu   $[[R1:[0-9]+]], $zero, -4
264 ; ALL:           and     $[[R2:[0-9]+]], $[[R0]], $[[R1]]
265 ; ALL:           andi    $[[R3:[0-9]+]], $[[R0]], 3
266 ; CHECK-EL:      sll     $[[R5:[0-9]+]], $[[R3]], 3
267 ; CHECK-EB:      xori    $[[R4:[0-9]+]], $[[R3]], 3
268 ; CHECK-EB:      sll     $[[R5:[0-9]+]], $[[R4]], 3
269 ; ALL:           ori     $[[R6:[0-9]+]], $zero, 255
270 ; ALL:           sllv    $[[R7:[0-9]+]], $[[R6]], $[[R5]]
271 ; ALL:           nor     $[[R8:[0-9]+]], $zero, $[[R7]]
272 ; ALL:           andi    $[[R9:[0-9]+]], $4, 255
273 ; ALL:           sllv    $[[R10:[0-9]+]], $[[R9]], $[[R5]]
274 ; ALL:           andi    $[[R11:[0-9]+]], $5, 255
275 ; ALL:           sllv    $[[R12:[0-9]+]], $[[R11]], $[[R5]]
276
277 ; ALL:       $[[BB0:[A-Z_0-9]+]]:
278 ; ALL:           ll      $[[R13:[0-9]+]], 0($[[R2]])
279 ; ALL:           and     $[[R14:[0-9]+]], $[[R13]], $[[R7]]
280 ; ALL:           bne     $[[R14]], $[[R10]], $[[BB1:[A-Z_0-9]+]]
281
282 ; ALL:           and     $[[R15:[0-9]+]], $[[R13]], $[[R8]]
283 ; ALL:           or      $[[R16:[0-9]+]], $[[R15]], $[[R12]]
284 ; ALL:           sc      $[[R16]], 0($[[R2]])
285 ; ALL:           beqz    $[[R16]], $[[BB0]]
286
287 ; ALL:       $[[BB1]]:
288 ; ALL:           srlv    $[[R17:[0-9]+]], $[[R14]], $[[R5]]
289
290 ; NO-SEB-SEH:    sll     $[[R18:[0-9]+]], $[[R17]], 24
291 ; NO-SEB-SEH:    sra     $2, $[[R18]], 24
292
293 ; HAS-SEB-SEH:   seb     $2, $[[R17]]
294 }
295
296 define i1 @AtomicCmpSwapRes8(i8* %ptr, i8 %oldval, i8 signext %newval) nounwind {
297 entry:
298   %0 = cmpxchg i8* %ptr, i8 %oldval, i8 %newval monotonic monotonic
299   %1 = extractvalue { i8, i1 } %0, 1
300   ret i1 %1
301 ; ALL-LABEL: AtomicCmpSwapRes8
302
303 ; ALL:           addiu   $[[R1:[0-9]+]], $zero, -4
304 ; ALL:           and     $[[R2:[0-9]+]], $4, $[[R1]]
305 ; ALL:           andi    $[[R3:[0-9]+]], $4, 3
306 ; CHECK-EL:      sll     $[[R5:[0-9]+]], $[[R3]], 3
307 ; CHECK-EB:      xori    $[[R4:[0-9]+]], $[[R3]], 3
308 ; CHECK-EB:      sll     $[[R5:[0-9]+]], $[[R4]], 3
309 ; ALL:           ori     $[[R6:[0-9]+]], $zero, 255
310 ; ALL:           sllv    $[[R7:[0-9]+]], $[[R6]], $[[R5]]
311 ; ALL:           nor     $[[R8:[0-9]+]], $zero, $[[R7]]
312 ; ALL:           andi    $[[R9:[0-9]+]], $5, 255
313 ; ALL:           sllv    $[[R10:[0-9]+]], $[[R9]], $[[R5]]
314 ; ALL:           andi    $[[R11:[0-9]+]], $6, 255
315 ; ALL:           sllv    $[[R12:[0-9]+]], $[[R11]], $[[R5]]
316
317 ; ALL:       $[[BB0:[A-Z_0-9]+]]:
318 ; ALL:           ll      $[[R13:[0-9]+]], 0($[[R2]])
319 ; ALL:           and     $[[R14:[0-9]+]], $[[R13]], $[[R7]]
320 ; ALL:           bne     $[[R14]], $[[R10]], $[[BB1:[A-Z_0-9]+]]
321
322 ; ALL:           and     $[[R15:[0-9]+]], $[[R13]], $[[R8]]
323 ; ALL:           or      $[[R16:[0-9]+]], $[[R15]], $[[R12]]
324 ; ALL:           sc      $[[R16]], 0($[[R2]])
325 ; ALL:           beqz    $[[R16]], $[[BB0]]
326
327 ; ALL:       $[[BB1]]:
328 ; ALL:           srlv    $[[R17:[0-9]+]], $[[R14]], $[[R5]]
329
330 ; NO-SEB-SEH:    sll     $[[R18:[0-9]+]], $[[R17]], 24
331 ; NO-SEB-SEH:    sra     $[[R19:[0-9]+]], $[[R18]], 24
332
333 ; HAS-SEB-SEH:   seb     $[[R19:[0-9]+]], $[[R17]]
334
335 ; ALL:           xor     $[[R20:[0-9]+]], $[[R19]], $5
336 ; ALL:           sltiu   $2, $[[R20]], 1
337 }
338
339 ; Check one i16 so that we cover the seh sign extend
340 @z = common global i16 0, align 1
341
342 define signext i16 @AtomicLoadAdd16(i16 signext %incr) nounwind {
343 entry:
344   %0 = atomicrmw add i16* @z, i16 %incr monotonic
345   ret i16 %0
346
347 ; ALL-LABEL: AtomicLoadAdd16:
348
349 ; MIPS32-ANY:    lw      $[[R0:[0-9]+]], %got(z)
350 ; MIPS64-ANY:    ld      $[[R0:[0-9]+]], %got_disp(z)(
351
352 ; ALL:           addiu   $[[R1:[0-9]+]], $zero, -4
353 ; ALL:           and     $[[R2:[0-9]+]], $[[R0]], $[[R1]]
354 ; ALL:           andi    $[[R3:[0-9]+]], $[[R0]], 3
355 ; CHECK-EB:      xori    $[[R4:[0-9]+]], $[[R3]], 2
356 ; CHECK-EB:      sll     $[[R5:[0-9]+]], $[[R4]], 3
357 ; CHECK-EL:      sll     $[[R5:[0-9]+]], $[[R3]], 3
358 ; ALL:           ori     $[[R6:[0-9]+]], $zero, 65535
359 ; ALL:           sllv    $[[R7:[0-9]+]], $[[R6]], $[[R5]]
360 ; ALL:           nor     $[[R8:[0-9]+]], $zero, $[[R7]]
361 ; ALL:           sllv    $[[R9:[0-9]+]], $4, $[[R5]]
362
363 ; ALL:       $[[BB0:[A-Z_0-9]+]]:
364 ; ALL:           ll      $[[R10:[0-9]+]], 0($[[R2]])
365 ; ALL:           addu    $[[R11:[0-9]+]], $[[R10]], $[[R9]]
366 ; ALL:           and     $[[R12:[0-9]+]], $[[R11]], $[[R7]]
367 ; ALL:           and     $[[R13:[0-9]+]], $[[R10]], $[[R8]]
368 ; ALL:           or      $[[R14:[0-9]+]], $[[R13]], $[[R12]]
369 ; ALL:           sc      $[[R14]], 0($[[R2]])
370 ; ALL:           beqz    $[[R14]], $[[BB0]]
371
372 ; ALL:           and     $[[R15:[0-9]+]], $[[R10]], $[[R7]]
373 ; ALL:           srlv    $[[R16:[0-9]+]], $[[R15]], $[[R5]]
374
375 ; NO-SEB-SEH:    sll     $[[R17:[0-9]+]], $[[R16]], 16
376 ; NO-SEB-SEH:    sra     $2, $[[R17]], 16
377
378 ; MIPS32R2:      seh     $2, $[[R16]]
379 }
380
381
382 @countsint = common global i32 0, align 4
383
384 define i32 @CheckSync(i32 %v) nounwind noinline {
385 entry:
386   %0 = atomicrmw add i32* @countsint, i32 %v seq_cst
387   ret i32 %0 
388
389 ; ALL-LABEL: CheckSync:
390
391 ; ALL:           sync
392 ; ALL:           ll
393 ; ALL:           sc
394 ; ALL:           beq
395 ; ALL:           sync
396 }
397
398 ; make sure that this assertion in
399 ; TwoAddressInstructionPass::TryInstructionTransform does not fail:
400 ;
401 ; line 1203: assert(TargetRegisterInfo::isVirtualRegister(regB) &&
402 ;
403 ; it failed when MipsDAGToDAGISel::ReplaceUsesWithZeroReg replaced an
404 ; operand of an atomic instruction with register $zero. 
405 @a = external global i32
406
407 define i32 @zeroreg() nounwind {
408 entry:
409   %pair0 = cmpxchg i32* @a, i32 1, i32 0 seq_cst seq_cst
410   %0 = extractvalue { i32, i1 } %pair0, 0
411   %1 = icmp eq i32 %0, 1
412   %conv = zext i1 %1 to i32
413   ret i32 %conv
414 }
415
416 ; Check that MIPS32R6 has the correct offset range.
417 ; FIXME: At the moment, we don't seem to do addr+offset for any atomic load/store.
418 define i32 @AtomicLoadAdd32_OffGt9Bit(i32 %incr) nounwind {
419 entry:
420   %0 = atomicrmw add i32* getelementptr(i32* @x, i32 256), i32 %incr monotonic
421   ret i32 %0
422
423 ; ALL-LABEL: AtomicLoadAdd32_OffGt9Bit:
424
425 ; MIPS32-ANY:    lw      $[[R0:[0-9]+]], %got(x)
426 ; MIPS64-ANY:    ld      $[[R0:[0-9]+]], %got_disp(x)(
427
428 ; ALL:           addiu   $[[PTR:[0-9]+]], $[[R0]], 1024
429 ; ALL:       $[[BB0:[A-Z_0-9]+]]:
430 ; ALL:           ll      $[[R1:[0-9]+]], 0($[[PTR]])
431 ; ALL:           addu    $[[R2:[0-9]+]], $[[R1]], $4
432 ; ALL:           sc      $[[R2]], 0($[[PTR]])
433 ; ALL:           beqz    $[[R2]], $[[BB0]]
434 }