1 ; Test 16-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 i16 @f1(i16 *%src, i16 %b) {
15 ; CHECK: sllg [[SHIFT:%r[1-9]+]], %r2, 3
16 ; CHECK: nill %r2, 65532
17 ; CHECK: l [[OLD:%r[0-9]+]], 0(%r2)
18 ; CHECK: [[LABEL:\.[^:]*]]:
19 ; CHECK: rll [[ROT:%r[0-9]+]], [[OLD]], 0([[SHIFT]])
20 ; CHECK: risbg [[ROT]], %r3, 32, 47, 16
21 ; CHECK: rll [[NEW:%r[0-9]+]], [[ROT]], 0({{%r[1-9]+}})
22 ; CHECK: cs [[OLD]], [[NEW]], 0(%r2)
24 ; CHECK: rll %r2, [[OLD]], 16([[SHIFT]])
27 ; CHECK-SHIFT-LABEL: f1:
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, 47, 16
36 ; CHECK-SHIFT: rll {{%r[0-9]+}}, {{%r[0-9]+}}, 0([[NEGSHIFT]])
38 ; CHECK-SHIFT: br %r14
39 %res = atomicrmw xchg i16 *%src, i16 %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 i16 @f2(i16 *%src) {
47 ; CHECK: lhi [[VALUE:%r[0-9]+]], -25536
48 ; CHECK: risbg {{%r[0-9]+}}, [[VALUE]], 32, 47, 16
51 ; CHECK-SHIFT-LABEL: f2:
52 ; CHECK-SHIFT: br %r14
53 %res = atomicrmw xchg i16 *%src, i16 40000 seq_cst