1 ; Test 64-bit signed comparisons between memory and a constant.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check ordered comparisons with 0.
6 define double @f1(double %a, double %b, i64 *%ptr) {
8 ; CHECK: cghsi 0(%r2), 0
13 %cond = icmp slt i64 %val, 0
14 %res = select i1 %cond, double %a, double %b
18 ; Check ordered comparisons with 1.
19 define double @f2(double %a, double %b, i64 *%ptr) {
21 ; CHECK: cghsi 0(%r2), 0
26 %cond = icmp slt i64 %val, 1
27 %res = select i1 %cond, double %a, double %b
31 ; Check ordered comparisons with the high end of the signed 16-bit range.
32 define double @f3(double %a, double %b, i64 *%ptr) {
34 ; CHECK: cghsi 0(%r2), 32767
39 %cond = icmp slt i64 %val, 32767
40 %res = select i1 %cond, double %a, double %b
44 ; Check the next value up, which can't use CGHSI.
45 define double @f4(double %a, double %b, i64 *%ptr) {
50 %cond = icmp slt i64 %val, 32768
51 %res = select i1 %cond, double %a, double %b
55 ; Check ordered comparisons with -1.
56 define double @f5(double %a, double %b, i64 *%ptr) {
58 ; CHECK: cghsi 0(%r2), -1
63 %cond = icmp slt i64 %val, -1
64 %res = select i1 %cond, double %a, double %b
68 ; Check ordered comparisons with the low end of the 16-bit signed range.
69 define double @f6(double %a, double %b, i64 *%ptr) {
71 ; CHECK: cghsi 0(%r2), -32768
76 %cond = icmp slt i64 %val, -32768
77 %res = select i1 %cond, double %a, double %b
81 ; Check the next value down, which should be treated as a positive value.
82 define double @f7(double %a, double %b, i64 *%ptr) {
87 %cond = icmp slt i64 %val, -32769
88 %res = select i1 %cond, double %a, double %b
92 ; Check equality comparisons with 0.
93 define double @f8(double %a, double %b, i64 *%ptr) {
95 ; CHECK: cghsi 0(%r2), 0
100 %cond = icmp eq i64 %val, 0
101 %res = select i1 %cond, double %a, double %b
105 ; Check equality comparisons with 1.
106 define double @f9(double %a, double %b, i64 *%ptr) {
108 ; CHECK: cghsi 0(%r2), 1
110 ; CHECK: ldr %f0, %f2
112 %val = load i64 *%ptr
113 %cond = icmp eq i64 %val, 1
114 %res = select i1 %cond, double %a, double %b
118 ; Check equality comparisons with the high end of the signed 16-bit range.
119 define double @f10(double %a, double %b, i64 *%ptr) {
121 ; CHECK: cghsi 0(%r2), 32767
123 ; CHECK: ldr %f0, %f2
125 %val = load i64 *%ptr
126 %cond = icmp eq i64 %val, 32767
127 %res = select i1 %cond, double %a, double %b
131 ; Check the next value up, which can't use CGHSI.
132 define double @f11(double %a, double %b, i64 *%ptr) {
136 %val = load i64 *%ptr
137 %cond = icmp eq i64 %val, 32768
138 %res = select i1 %cond, double %a, double %b
142 ; Check equality comparisons with -1.
143 define double @f12(double %a, double %b, i64 *%ptr) {
145 ; CHECK: cghsi 0(%r2), -1
147 ; CHECK: ldr %f0, %f2
149 %val = load i64 *%ptr
150 %cond = icmp eq i64 %val, -1
151 %res = select i1 %cond, double %a, double %b
155 ; Check equality comparisons with the low end of the 16-bit signed range.
156 define double @f13(double %a, double %b, i64 *%ptr) {
158 ; CHECK: cghsi 0(%r2), -32768
160 ; CHECK: ldr %f0, %f2
162 %val = load i64 *%ptr
163 %cond = icmp eq i64 %val, -32768
164 %res = select i1 %cond, double %a, double %b
168 ; Check the next value down, which should be treated as a positive value.
169 define double @f14(double %a, double %b, i64 *%ptr) {
173 %val = load i64 *%ptr
174 %cond = icmp eq i64 %val, -32769
175 %res = select i1 %cond, double %a, double %b
179 ; Check the high end of the CGHSI range.
180 define double @f15(double %a, double %b, i64 %i1, i64 *%base) {
182 ; CHECK: cghsi 4088(%r3), 0
184 ; CHECK: ldr %f0, %f2
186 %ptr = getelementptr i64 *%base, i64 511
187 %val = load i64 *%ptr
188 %cond = icmp slt i64 %val, 0
189 %res = select i1 %cond, double %a, double %b
193 ; Check the next doubleword up, which needs separate address logic,
194 define double @f16(double %a, double %b, i64 *%base) {
196 ; CHECK: aghi %r2, 4096
197 ; CHECK: cghsi 0(%r2), 0
199 ; CHECK: ldr %f0, %f2
201 %ptr = getelementptr i64 *%base, i64 512
202 %val = load i64 *%ptr
203 %cond = icmp slt i64 %val, 0
204 %res = select i1 %cond, double %a, double %b
208 ; Check negative offsets, which also need separate address logic.
209 define double @f17(double %a, double %b, i64 *%base) {
211 ; CHECK: aghi %r2, -8
212 ; CHECK: cghsi 0(%r2), 0
214 ; CHECK: ldr %f0, %f2
216 %ptr = getelementptr i64 *%base, i64 -1
217 %val = load i64 *%ptr
218 %cond = icmp slt i64 %val, 0
219 %res = select i1 %cond, double %a, double %b
223 ; Check that CGHSI does not allow indices.
224 define double @f18(double %a, double %b, i64 %base, i64 %index) {
226 ; CHECK: agr {{%r2, %r3|%r3, %r2}}
227 ; CHECK: cghsi 0({{%r[23]}}), 0
229 ; CHECK: ldr %f0, %f2
231 %add = add i64 %base, %index
232 %ptr = inttoptr i64 %add to i64 *
233 %val = load i64 *%ptr
234 %cond = icmp slt i64 %val, 0
235 %res = select i1 %cond, double %a, double %b