• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test 16-bit atomic exchange.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-SHIFT
5
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).
13define i16 @f1(i16 *%src, i16 %b) {
14; CHECK-LABEL: f1:
15; CHECK: risbg [[RISBG:%r[1-9]+]], %r2, 0, 189, 0{{$}}
16; CHECK-DAG: sll %r2, 3
17; CHECK-DAG: l [[OLD:%r[0-9]+]], 0([[RISBG]])
18; CHECK: [[LABEL:\.[^:]*]]:
19; CHECK: rll [[ROT:%r[0-9]+]], [[OLD]], 0(%r2)
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([[RISBG]])
23; CHECK: jl [[LABEL]]
24; CHECK: rll %r2, [[OLD]], 16(%r2)
25; CHECK: br %r14
26;
27; CHECK-SHIFT-LABEL: f1:
28; CHECK-SHIFT-NOT: %r3
29; CHECK-SHIFT: sll %r2, 3
30; CHECK-SHIFT-NOT: %r3
31; CHECK-SHIFT: lcr [[NEGSHIFT:%r[1-9]+]], %r2
32; CHECK-SHIFT-NOT: %r3
33; CHECK-SHIFT: rll
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]])
37; CHECK-SHIFT: rll
38; CHECK-SHIFT: br %r14
39  %res = atomicrmw xchg i16 *%src, i16 %b seq_cst
40  ret i16 %res
41}
42
43; Check exchange with a constant.  We should force the constant into
44; a register and use the sequence above.
45define i16 @f2(i16 *%src) {
46; CHECK-LABEL: f2:
47; CHECK: lhi [[VALUE:%r[0-9]+]], -25536
48; CHECK: risbg {{%r[0-9]+}}, [[VALUE]], 32, 47, 16
49; CHECK: br %r14
50;
51; CHECK-SHIFT-LABEL: f2:
52; CHECK-SHIFT: br %r14
53  %res = atomicrmw xchg i16 *%src, i16 40000 seq_cst
54  ret i16 %res
55}
56