blob: 47372658165e2d0979a4a0ec3619c0f557bf56e9 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 16-bit signed ordered comparisons between memory and a constant.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Check comparisons with 0.
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: chhsi 0(%r2), 0
Ulrich Weigand2eb027d2016-04-07 16:11:44 +00009; CHECK-NEXT: blr %r14
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 slt i16 %val, 0
14 %res = select i1 %cond, double %a, double %b
15 ret double %res
16}
17
18; Check comparisons with 1.
19define double @f2(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000020; CHECK-LABEL: f2:
Richard Sandiforda0757082013-08-01 10:29:45 +000021; CHECK: chhsi 0(%r2), 0
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000022; CHECK-NEXT: bler %r14
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 slt i16 %val, 1
27 %res = select i1 %cond, double %a, double %b
28 ret double %res
29}
30
31; Check a value near the high end of the signed 16-bit range.
32define double @f3(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000033; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000034; CHECK: chhsi 0(%r2), 32766
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000035; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000036; CHECK: ldr %f0, %f2
37; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000038 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000039 %cond = icmp slt i16 %val, 32766
40 %res = select i1 %cond, double %a, double %b
41 ret double %res
42}
43
44; Check comparisons with -1.
45define double @f4(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000046; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000047; CHECK: chhsi 0(%r2), -1
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000048; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000049; CHECK: ldr %f0, %f2
50; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000051 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000052 %cond = icmp slt i16 %val, -1
53 %res = select i1 %cond, double %a, double %b
54 ret double %res
55}
56
57; Check a value near the low end of the 16-bit signed range.
58define double @f5(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000059; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000060; CHECK: chhsi 0(%r2), -32766
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000061; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000062; CHECK: ldr %f0, %f2
63; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000064 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000065 %cond = icmp slt i16 %val, -32766
66 %res = select i1 %cond, double %a, double %b
67 ret double %res
68}
69
70; Check the high end of the CHHSI range.
71define double @f6(double %a, double %b, i16 %i1, i16 *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +000072; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000073; CHECK: chhsi 4094(%r3), 0
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000074; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000075; CHECK: ldr %f0, %f2
76; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000077 %ptr = getelementptr i16, i16 *%base, i64 2047
David Blaikiea79ac142015-02-27 21:17:42 +000078 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000079 %cond = icmp slt i16 %val, 0
80 %res = select i1 %cond, double %a, double %b
81 ret double %res
82}
83
84; Check the next halfword up, which needs separate address logic,
85define double @f7(double %a, double %b, i16 *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +000086; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000087; CHECK: aghi %r2, 4096
88; CHECK: chhsi 0(%r2), 0
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000089; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000090; CHECK: ldr %f0, %f2
91; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +000092 %ptr = getelementptr i16, i16 *%base, i64 2048
David Blaikiea79ac142015-02-27 21:17:42 +000093 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000094 %cond = icmp slt i16 %val, 0
95 %res = select i1 %cond, double %a, double %b
96 ret double %res
97}
98
99; Check negative offsets, which also need separate address logic.
100define double @f8(double %a, double %b, i16 *%base) {
Stephen Lind24ab202013-07-14 06:24:09 +0000101; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000102; CHECK: aghi %r2, -2
103; CHECK: chhsi 0(%r2), 0
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000104; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000105; CHECK: ldr %f0, %f2
106; CHECK: br %r14
David Blaikie79e6c742015-02-27 19:29:02 +0000107 %ptr = getelementptr i16, i16 *%base, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000108 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000109 %cond = icmp slt i16 %val, 0
110 %res = select i1 %cond, double %a, double %b
111 ret double %res
112}
113
114; Check that CHHSI does not allow indices.
115define double @f9(double %a, double %b, i64 %base, i64 %index) {
Stephen Lind24ab202013-07-14 06:24:09 +0000116; CHECK-LABEL: f9:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000117; CHECK: agr {{%r2, %r3|%r3, %r2}}
118; CHECK: chhsi 0({{%r[23]}}), 0
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000119; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000120; CHECK: ldr %f0, %f2
121; CHECK: br %r14
122 %add = add i64 %base, %index
123 %ptr = inttoptr i64 %add to i16 *
David Blaikiea79ac142015-02-27 21:17:42 +0000124 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000125 %cond = icmp slt i16 %val, 0
126 %res = select i1 %cond, double %a, double %b
127 ret double %res
128}