1 ; Test 16-bit unsigned comparisons between memory and a constant.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check a value near the low end of the unsigned 16-bit range.
6 define double @f1(double %a, double %b, ptr %ptr) {
8 ; CHECK: clhhsi 0(%r2), 1
12 %val = load i16, ptr %ptr
13 %cond = icmp ugt i16 %val, 1
14 %res = select i1 %cond, double %a, double %b
18 ; Check a value near the high end of the unsigned 16-bit range.
19 define double @f2(double %a, double %b, ptr %ptr) {
21 ; CHECK: clhhsi 0(%r2), 65534
22 ; CHECK-NEXT: blr %r14
25 %val = load i16, ptr %ptr
26 %cond = icmp ult i16 %val, 65534
27 %res = select i1 %cond, double %a, double %b
31 ; Check the high end of the CLHHSI range.
32 define double @f3(double %a, double %b, i16 %i1, ptr %base) {
34 ; CHECK: clhhsi 4094(%r3), 1
35 ; CHECK-NEXT: bhr %r14
38 %ptr = getelementptr i16, ptr %base, i64 2047
39 %val = load i16, ptr %ptr
40 %cond = icmp ugt i16 %val, 1
41 %res = select i1 %cond, double %a, double %b
45 ; Check the next halfword up, which needs separate address logic,
46 define double @f4(double %a, double %b, ptr %base) {
48 ; CHECK: aghi %r2, 4096
49 ; CHECK: clhhsi 0(%r2), 1
50 ; CHECK-NEXT: bhr %r14
53 %ptr = getelementptr i16, ptr %base, i64 2048
54 %val = load i16, ptr %ptr
55 %cond = icmp ugt i16 %val, 1
56 %res = select i1 %cond, double %a, double %b
60 ; Check negative offsets, which also need separate address logic.
61 define double @f5(double %a, double %b, ptr %base) {
64 ; CHECK: clhhsi 0(%r2), 1
65 ; CHECK-NEXT: bhr %r14
68 %ptr = getelementptr i16, ptr %base, i64 -1
69 %val = load i16, ptr %ptr
70 %cond = icmp ugt i16 %val, 1
71 %res = select i1 %cond, double %a, double %b
75 ; Check that CLHHSI does not allow indices.
76 define double @f6(double %a, double %b, i64 %base, i64 %index) {
78 ; CHECK: agr {{%r2, %r3|%r3, %r2}}
79 ; CHECK: clhhsi 0({{%r[23]}}), 1
80 ; CHECK-NEXT: bhr %r14
83 %add = add i64 %base, %index
84 %ptr = inttoptr i64 %add to ptr
85 %val = load i16, ptr %ptr
86 %cond = icmp ugt i16 %val, 1
87 %res = select i1 %cond, double %a, double %b