blob: df6b62616a79ef796b6e86ca2f6a30057ce012bc [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 16-bit unsigned comparisons between memory and a constant.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Check a value near the low end of the unsigned 16-bit range.
6define double @f1(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +00007; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00008; CHECK: clhhsi 0(%r2), 1
Richard Sandiford586f4172013-05-21 08:53:17 +00009; CHECK-NEXT: jh
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000010; CHECK: ldr %f0, %f2
11; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000012 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000013 %cond = icmp ugt i16 %val, 1
14 %res = select i1 %cond, double %a, double %b
15 ret double %res
16}
17
18; Check a value near the high end of the unsigned 16-bit range.
19define double @f2(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000020; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000021; CHECK: clhhsi 0(%r2), 65534
Richard Sandiford586f4172013-05-21 08:53:17 +000022; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000023; CHECK: ldr %f0, %f2
24; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000025 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000026 %cond = icmp ult i16 %val, 65534
27 %res = select i1 %cond, double %a, double %b
28 ret double %res
29}
30
31; Check the high end of the CLHHSI range.
32define double @f3(double %a, double %b, i16 %i1, i16 *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +000033; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000034; CHECK: clhhsi 4094(%r3), 1
Richard Sandiford586f4172013-05-21 08:53:17 +000035; CHECK-NEXT: jh
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000036; CHECK: ldr %f0, %f2
37; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000038 %ptr = getelementptr i16, i16 *%base, i64 2047
David Blaikiea79ac142015-02-27 21:17:42 +000039 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000040 %cond = icmp ugt i16 %val, 1
41 %res = select i1 %cond, double %a, double %b
42 ret double %res
43}
44
45; Check the next halfword up, which needs separate address logic,
46define double @f4(double %a, double %b, i16 *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +000047; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000048; CHECK: aghi %r2, 4096
49; CHECK: clhhsi 0(%r2), 1
Richard Sandiford586f4172013-05-21 08:53:17 +000050; CHECK-NEXT: jh
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000051; CHECK: ldr %f0, %f2
52; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000053 %ptr = getelementptr i16, i16 *%base, i64 2048
David Blaikiea79ac142015-02-27 21:17:42 +000054 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000055 %cond = icmp ugt i16 %val, 1
56 %res = select i1 %cond, double %a, double %b
57 ret double %res
58}
59
60; Check negative offsets, which also need separate address logic.
61define double @f5(double %a, double %b, i16 *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +000062; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000063; CHECK: aghi %r2, -2
64; CHECK: clhhsi 0(%r2), 1
Richard Sandiford586f4172013-05-21 08:53:17 +000065; CHECK-NEXT: jh
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000066; CHECK: ldr %f0, %f2
67; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000068 %ptr = getelementptr i16, i16 *%base, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +000069 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000070 %cond = icmp ugt i16 %val, 1
71 %res = select i1 %cond, double %a, double %b
72 ret double %res
73}
74
75; Check that CLHHSI does not allow indices.
76define double @f6(double %a, double %b, i64 %base, i64 %index) {
Stephen Lind24ab202013-07-14 06:24:09 +000077; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000078; CHECK: agr {{%r2, %r3|%r3, %r2}}
79; CHECK: clhhsi 0({{%r[23]}}), 1
Richard Sandiford586f4172013-05-21 08:53:17 +000080; CHECK-NEXT: jh
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000081; CHECK: ldr %f0, %f2
82; CHECK: br %r14
83 %add = add i64 %base, %index
84 %ptr = inttoptr i64 %add to i16 *
David Blaikiea79ac142015-02-27 21:17:42 +000085 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000086 %cond = icmp ugt i16 %val, 1
87 %res = select i1 %cond, double %a, double %b
88 ret double %res
89}