• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test 16-bit compare and swap.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-MAIN
4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-SHIFT
5
6; Check compare and swap 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).
13define i16 @f1(i16 %dummy, i16 *%src, i16 %cmp, i16 %swap) {
14; CHECK-MAIN-LABEL: f1:
15; CHECK-MAIN: risbg [[RISBG:%r[1-9]+]], %r3, 0, 189, 0{{$}}
16; CHECK-MAIN: sll %r3, 3
17; CHECK-MAIN: l [[OLD:%r[0-9]+]], 0([[RISBG]])
18; CHECK-MAIN: [[LOOP:\.[^ ]*]]:
19; CHECK-MAIN: rll %r2, [[OLD]], 16(%r3)
20; CHECK-MAIN: risbg %r4, %r2, 32, 47, 0
21; CHECK-MAIN: crjlh %r2, %r4, [[EXIT:\.[^ ]*]]
22; CHECK-MAIN: risbg %r5, %r2, 32, 47, 0
23; CHECK-MAIN: rll [[NEW:%r[0-9]+]], %r5, -16({{%r[1-9]+}})
24; CHECK-MAIN: cs [[OLD]], [[NEW]], 0([[RISBG]])
25; CHECK-MAIN: jl [[LOOP]]
26; CHECK-MAIN: [[EXIT]]:
27; CHECK-MAIN-NOT: %r2
28; CHECK-MAIN: br %r14
29;
30; CHECK-SHIFT-LABEL: f1:
31; CHECK-SHIFT: sll %r3, 3
32; CHECK-SHIFT: lcr [[NEGSHIFT:%r[1-9]+]], %r3
33; CHECK-SHIFT: rll
34; CHECK-SHIFT: rll {{%r[0-9]+}}, %r5, -16([[NEGSHIFT]])
35  %pair = cmpxchg i16 *%src, i16 %cmp, i16 %swap seq_cst seq_cst
36  %res = extractvalue { i16, i1 } %pair, 0
37  ret i16 %res
38}
39
40; Check compare and swap with constants.  We should force the constants into
41; registers and use the sequence above.
42define i16 @f2(i16 *%src) {
43; CHECK-LABEL: f2:
44; CHECK: lhi [[CMP:%r[0-9]+]], 42
45; CHECK: risbg [[CMP]], {{%r[0-9]+}}, 32, 47, 0
46; CHECK: risbg
47; CHECK: br %r14
48;
49; CHECK-SHIFT-LABEL: f2:
50; CHECK-SHIFT: lhi [[SWAP:%r[0-9]+]], 88
51; CHECK-SHIFT: risbg
52; CHECK-SHIFT: risbg [[SWAP]], {{%r[0-9]+}}, 32, 47, 0
53; CHECK-SHIFT: br %r14
54  %pair = cmpxchg i16 *%src, i16 42, i16 88 seq_cst seq_cst
55  %res = extractvalue { i16, i1 } %pair, 0
56  ret i16 %res
57}
58