1 ; Test 8-bit atomic exchange.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-SHIFT
6 ; Check exchange with a variable.
7 ; - CHECK is for the main loop.
8 ; - CHECK-SHIFT makes sure that the negated shift count used by the second
9 ; RLL is set up correctly. The negation is independent of the NILL and L
10 ; tested in CHECK. CHECK-SHIFT also checks that %r3 is not modified before
11 ; being used in the RISBG (in contrast to things like atomic addition,
12 ; which shift %r3 left so that %b is at the high end of the word).
13 define i8 @f1(i8 *%src, i8 %b) {
15 ; CHECK-DAG: sllg [[SHIFT:%r[1-9]+]], %r2, 3
16 ; CHECK-DAG: risbg [[BASE:%r[1-9]+]], %r2, 0, 189, 0
17 ; CHECK: l [[OLD:%r[0-9]+]], 0([[BASE]])
18 ; CHECK: [[LABEL:\.[^:]*]]:
19 ; CHECK: rll [[ROT:%r[0-9]+]], [[OLD]], 0([[SHIFT]])
20 ; CHECK: risbg [[ROT]], %r3, 32, 39, 24
21 ; CHECK: rll [[NEW:%r[0-9]+]], [[ROT]], 0({{%r[1-9]+}})
22 ; CHECK: cs [[OLD]], [[NEW]], 0([[BASE]])
23 ; CHECK: jlh [[LABEL]]
24 ; CHECK: rll %r2, [[OLD]], 8([[SHIFT]])
28 ; CHECK-SHIFT-NOT: %r3
29 ; CHECK-SHIFT: sllg [[SHIFT:%r[1-9]+]], %r2, 3
30 ; CHECK-SHIFT-NOT: %r3
31 ; CHECK-SHIFT: lcr [[NEGSHIFT:%r[1-9]+]], [[SHIFT]]
32 ; CHECK-SHIFT-NOT: %r3
34 ; CHECK-SHIFT-NOT: %r3
35 ; CHECK-SHIFT: risbg {{%r[0-9]+}}, %r3, 32, 39, 24
36 ; CHECK-SHIFT: rll {{%r[0-9]+}}, {{%r[0-9]+}}, 0([[NEGSHIFT]])
38 ; CHECK-SHIFT: br %r14
39 %res = atomicrmw xchg i8 *%src, i8 %b seq_cst
43 ; Check exchange with a constant. We should force the constant into
44 ; a register and use the sequence above.
45 define i8 @f2(i8 *%src) {
47 ; CHECK: lhi [[VALUE:%r[0-9]+]], 88
48 ; CHECK: risbg {{%r[0-9]+}}, [[VALUE]], 32, 39, 24
52 ; CHECK-SHIFT: br %r14
53 %res = atomicrmw xchg i8 *%src, i8 88 seq_cst