1 ; Test 16-bit atomic subtractions.
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-SHIFT1
5 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s -check-prefix=CHECK-SHIFT2
7 ; Check subtraction of a variable.
8 ; - CHECK is for the main loop.
9 ; - CHECK-SHIFT1 makes sure that the negated shift count used by the second
10 ; RLL is set up correctly. The negation is independent of the NILL and L
12 ; - CHECK-SHIFT2 makes sure that %b is shifted into the high part of the word
13 ; before being used. This shift is independent of the other loop prologue
15 define i16 @f1(i16 *%src, i16 %b) {
17 ; CHECK: sllg [[SHIFT:%r[1-9]+]], %r2, 3
18 ; CHECK: nill %r2, 65532
19 ; CHECK: l [[OLD:%r[0-9]+]], 0(%r2)
20 ; CHECK: [[LABEL:\.[^:]*]]:
21 ; CHECK: rll [[ROT:%r[0-9]+]], [[OLD]], 0([[SHIFT]])
22 ; CHECK: sr [[ROT]], %r3
23 ; CHECK: rll [[NEW:%r[0-9]+]], [[ROT]], 0({{%r[1-9]+}})
24 ; CHECK: cs [[OLD]], [[NEW]], 0(%r2)
26 ; CHECK: rll %r2, [[OLD]], 16([[SHIFT]])
29 ; CHECK-SHIFT1-LABEL: f1:
30 ; CHECK-SHIFT1: sllg [[SHIFT:%r[1-9]+]], %r2, 3
31 ; CHECK-SHIFT1: lcr [[NEGSHIFT:%r[1-9]+]], [[SHIFT]]
33 ; CHECK-SHIFT1: rll {{%r[0-9]+}}, {{%r[0-9]+}}, 0([[NEGSHIFT]])
35 ; CHECK-SHIFT1: br %r14
37 ; CHECK-SHIFT2-LABEL: f1:
38 ; CHECK-SHIFT2: sll %r3, 16
40 ; CHECK-SHIFT2: sr {{%r[0-9]+}}, %r3
43 ; CHECK-SHIFT2: br %r14
44 %res = atomicrmw sub i16 *%src, i16 %b seq_cst
48 ; Check the minimum signed value. We add 0x80000000 to the rotated word.
49 define i16 @f2(i16 *%src) {
51 ; CHECK: sllg [[SHIFT:%r[1-9]+]], %r2, 3
52 ; CHECK: nill %r2, 65532
53 ; CHECK: l [[OLD:%r[0-9]+]], 0(%r2)
54 ; CHECK: [[LABEL:\.[^:]*]]:
55 ; CHECK: rll [[ROT:%r[0-9]+]], [[OLD]], 0([[SHIFT]])
56 ; CHECK: afi [[ROT]], -2147483648
57 ; CHECK: rll [[NEW:%r[0-9]+]], [[ROT]], 0([[NEGSHIFT:%r[1-9]+]])
58 ; CHECK: cs [[OLD]], [[NEW]], 0(%r2)
60 ; CHECK: rll %r2, [[OLD]], 16([[SHIFT]])
63 ; CHECK-SHIFT1-LABEL: f2:
64 ; CHECK-SHIFT1: sllg [[SHIFT:%r[1-9]+]], %r2, 3
65 ; CHECK-SHIFT1: lcr [[NEGSHIFT:%r[1-9]+]], [[SHIFT]]
67 ; CHECK-SHIFT1: rll {{%r[0-9]+}}, {{%r[0-9]+}}, 0([[NEGSHIFT]])
69 ; CHECK-SHIFT1: br %r14
71 ; CHECK-SHIFT2-LABEL: f2:
72 ; CHECK-SHIFT2: br %r14
73 %res = atomicrmw sub i16 *%src, i16 -32768 seq_cst
77 ; Check subtraction of -1. We add 0x00010000 to the rotated word.
78 define i16 @f3(i16 *%src) {
80 ; CHECK: afi [[ROT]], 65536
83 ; CHECK-SHIFT1-LABEL: f3:
84 ; CHECK-SHIFT1: br %r14
85 ; CHECK-SHIFT2-LABEL: f3:
86 ; CHECK-SHIFT2: br %r14
87 %res = atomicrmw sub i16 *%src, i16 -1 seq_cst
91 ; Check subtraction of 1. We add 0xffff0000 to the rotated word.
92 define i16 @f4(i16 *%src) {
94 ; CHECK: afi [[ROT]], -65536
97 ; CHECK-SHIFT1-LABEL: f4:
98 ; CHECK-SHIFT1: br %r14
99 ; CHECK-SHIFT2-LABEL: f4:
100 ; CHECK-SHIFT2: br %r14
101 %res = atomicrmw sub i16 *%src, i16 1 seq_cst
105 ; Check the maximum signed value. We add 0x80010000 to the rotated word.
106 define i16 @f5(i16 *%src) {
108 ; CHECK: afi [[ROT]], -2147418112
111 ; CHECK-SHIFT1-LABEL: f5:
112 ; CHECK-SHIFT1: br %r14
113 ; CHECK-SHIFT2-LABEL: f5:
114 ; CHECK-SHIFT2: br %r14
115 %res = atomicrmw sub i16 *%src, i16 32767 seq_cst
119 ; Check subtraction of a large unsigned value. We add 0x00020000 to the
121 define i16 @f6(i16 *%src) {
123 ; CHECK: afi [[ROT]], 131072
126 ; CHECK-SHIFT1-LABEL: f6:
127 ; CHECK-SHIFT1: br %r14
128 ; CHECK-SHIFT2-LABEL: f6:
129 ; CHECK-SHIFT2: br %r14
130 %res = atomicrmw sub i16 *%src, i16 65534 seq_cst