1 ; Test 32-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, ptr %ptr) {
9 ; CHECK: clfhsi 0(%r2), 1
10 ; CHECK-NEXT: bhr %r14
13 %val = load i32, ptr %ptr
14 %cond = icmp ugt i32 %val, 1
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, ptr %ptr) {
22 ; CHECK: clfhsi 0(%r2), 65535
23 ; CHECK-NEXT: blr %r14
26 %val = load i32, ptr %ptr
27 %cond = icmp ult i32 %val, 65535
28 %res = select i1 %cond, double %a, double %b
32 ; Check the next value up, which can't use CLFHSI.
33 define double @f3(double %a, double %b, ptr %ptr) {
37 %val = load i32, ptr %ptr
38 %cond = icmp ult i32 %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 CLFHSI to CHSI.
45 define double @f4(double %a, double %b, ptr %ptr) {
47 ; CHECK: clfhsi 0(%r2), 32768
48 ; CHECK-NEXT: ber %r14
51 %val = load i32, ptr %ptr
52 %cond = icmp eq i32 %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, ptr %ptr) {
60 ; CHECK: clfhsi 0(%r2), 65535
61 ; CHECK-NEXT: ber %r14
64 %val = load i32, ptr %ptr
65 %cond = icmp eq i32 %val, 65535
66 %res = select i1 %cond, double %a, double %b
70 ; Check the next value up, which can't use CLFHSI.
71 define double @f6(double %a, double %b, ptr %ptr) {
75 %val = load i32, ptr %ptr
76 %cond = icmp eq i32 %val, 65536
77 %res = select i1 %cond, double %a, double %b
81 ; Check the high end of the CLFHSI range.
82 define double @f7(double %a, double %b, i32 %i1, ptr %base) {
84 ; CHECK: clfhsi 4092(%r3), 1
85 ; CHECK-NEXT: bhr %r14
88 %ptr = getelementptr i32, ptr %base, i64 1023
89 %val = load i32, ptr %ptr
90 %cond = icmp ugt i32 %val, 1
91 %res = select i1 %cond, double %a, double %b
95 ; Check the next word up, which needs separate address logic,
96 define double @f8(double %a, double %b, ptr %base) {
98 ; CHECK: aghi %r2, 4096
99 ; CHECK: clfhsi 0(%r2), 1
100 ; CHECK-NEXT: bhr %r14
101 ; CHECK: ldr %f0, %f2
103 %ptr = getelementptr i32, ptr %base, i64 1024
104 %val = load i32, ptr %ptr
105 %cond = icmp ugt i32 %val, 1
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, ptr %base) {
113 ; CHECK: aghi %r2, -4
114 ; CHECK: clfhsi 0(%r2), 1
115 ; CHECK-NEXT: bhr %r14
116 ; CHECK: ldr %f0, %f2
118 %ptr = getelementptr i32, ptr %base, i64 -1
119 %val = load i32, ptr %ptr
120 %cond = icmp ugt i32 %val, 1
121 %res = select i1 %cond, double %a, double %b
125 ; Check that CLFHSI 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: clfhsi 0({{%r[23]}}), 1
130 ; CHECK-NEXT: bhr %r14
131 ; CHECK: ldr %f0, %f2
133 %add = add i64 %base, %index
134 %ptr = inttoptr i64 %add to ptr
135 %val = load i32, ptr %ptr
136 %cond = icmp ugt i32 %val, 1
137 %res = select i1 %cond, double %a, double %b