1 ; Test 64-bit unsigned comparisons between memory and a constant.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check ordered comparisons with a constant near the low end of the unsigned
7 define double @f1(double %a, double %b, i64 *%ptr) {
9 ; CHECK: clghsi 0(%r2), 2
10 ; CHECK-NEXT: blr %r14
13 %val = load i64, i64 *%ptr
14 %cond = icmp ult i64 %val, 2
15 %res = select i1 %cond, double %a, double %b
19 ; Check ordered comparisons with the high end of the unsigned 16-bit range.
20 define double @f2(double %a, double %b, i64 *%ptr) {
22 ; CHECK: clghsi 0(%r2), 65535
23 ; CHECK-NEXT: blr %r14
26 %val = load i64, i64 *%ptr
27 %cond = icmp ult i64 %val, 65535
28 %res = select i1 %cond, double %a, double %b
32 ; Check the next value up, which can't use CLGHSI.
33 define double @f3(double %a, double %b, i64 *%ptr) {
37 %val = load i64, i64 *%ptr
38 %cond = icmp ult i64 %val, 65536
39 %res = select i1 %cond, double %a, double %b
43 ; Check equality comparisons with 32768, the lowest value for which
44 ; we prefer CLGHSI to CGHSI.
45 define double @f4(double %a, double %b, i64 *%ptr) {
47 ; CHECK: clghsi 0(%r2), 32768
48 ; CHECK-NEXT: ber %r14
51 %val = load i64, i64 *%ptr
52 %cond = icmp eq i64 %val, 32768
53 %res = select i1 %cond, double %a, double %b
57 ; Check equality comparisons with the high end of the unsigned 16-bit range.
58 define double @f5(double %a, double %b, i64 *%ptr) {
60 ; CHECK: clghsi 0(%r2), 65535
61 ; CHECK-NEXT: ber %r14
64 %val = load i64, i64 *%ptr
65 %cond = icmp eq i64 %val, 65535
66 %res = select i1 %cond, double %a, double %b
70 ; Check the next value up, which can't use CLGHSI.
71 define double @f6(double %a, double %b, i64 *%ptr) {
75 %val = load i64, i64 *%ptr
76 %cond = icmp eq i64 %val, 65536
77 %res = select i1 %cond, double %a, double %b
81 ; Check the high end of the CLGHSI range.
82 define double @f7(double %a, double %b, i64 %i1, i64 *%base) {
84 ; CHECK: clghsi 4088(%r3), 2
85 ; CHECK-NEXT: blr %r14
88 %ptr = getelementptr i64, i64 *%base, i64 511
89 %val = load i64, i64 *%ptr
90 %cond = icmp ult i64 %val, 2
91 %res = select i1 %cond, double %a, double %b
95 ; Check the next doubleword up, which needs separate address logic,
96 define double @f8(double %a, double %b, i64 *%base) {
98 ; CHECK: aghi %r2, 4096
99 ; CHECK: clghsi 0(%r2), 2
100 ; CHECK-NEXT: blr %r14
101 ; CHECK: ldr %f0, %f2
103 %ptr = getelementptr i64, i64 *%base, i64 512
104 %val = load i64, i64 *%ptr
105 %cond = icmp ult i64 %val, 2
106 %res = select i1 %cond, double %a, double %b
110 ; Check negative offsets, which also need separate address logic.
111 define double @f9(double %a, double %b, i64 *%base) {
113 ; CHECK: aghi %r2, -8
114 ; CHECK: clghsi 0(%r2), 2
115 ; CHECK-NEXT: blr %r14
116 ; CHECK: ldr %f0, %f2
118 %ptr = getelementptr i64, i64 *%base, i64 -1
119 %val = load i64, i64 *%ptr
120 %cond = icmp ult i64 %val, 2
121 %res = select i1 %cond, double %a, double %b
125 ; Check that CLGHSI does not allow indices.
126 define double @f10(double %a, double %b, i64 %base, i64 %index) {
128 ; CHECK: agr {{%r2, %r3|%r3, %r2}}
129 ; CHECK: clghsi 0({{%r[23]}}), 2
130 ; CHECK-NEXT: blr %r14
131 ; CHECK: ldr %f0, %f2
133 %add = add i64 %base, %index
134 %ptr = inttoptr i64 %add to i64 *
135 %val = load i64, i64 *%ptr
136 %cond = icmp ult i64 %val, 2
137 %res = select i1 %cond, double %a, double %b