blob: 45c5c789dd501f44b54154fca8e62c753125e23c [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 64-bit ordered comparisons that are really between a memory halfword
2; and a constant.
3;
4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5
6; Check unsigned comparison near the low end of the CLHHSI range, using zero
7; extension.
8define double @f1(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +00009; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000010; CHECK: clhhsi 0(%r2), 1
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000011; CHECK-NEXT: bhr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000012; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000013 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000014 %ext = zext i16 %val to i64
15 %cond = icmp ugt i64 %ext, 1
16 %res = select i1 %cond, double %a, double %b
17 ret double %res
18}
19
20; Check unsigned comparison near the low end of the CLHHSI range, using sign
21; extension.
22define double @f2(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000023; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000024; CHECK: clhhsi 0(%r2), 1
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000025; CHECK-NEXT: bhr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000026; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000027 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000028 %ext = sext i16 %val to i64
29 %cond = icmp ugt i64 %ext, 1
30 %res = select i1 %cond, double %a, double %b
31 ret double %res
32}
33
34; Check unsigned comparison near the high end of the CLHHSI range, using zero
35; extension.
36define double @f3(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000037; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000038; CHECK: clhhsi 0(%r2), 65534
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000039; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000040; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000041 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000042 %ext = zext i16 %val to i64
43 %cond = icmp ult i64 %ext, 65534
44 %res = select i1 %cond, double %a, double %b
45 ret double %res
46}
47
48; Check unsigned comparison near the high end of the CLHHSI range, using sign
49; extension.
50define double @f4(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000051; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000052; CHECK: clhhsi 0(%r2), 65534
Ulrich Weigand2eb027d2016-04-07 16:11:44 +000053; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000054; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000055 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000056 %ext = sext i16 %val to i64
57 %cond = icmp ult i64 %ext, -2
58 %res = select i1 %cond, double %a, double %b
59 ret double %res
60}
61
62; Check unsigned comparison above the high end of the CLHHSI range, using zero
63; extension. The condition is always true.
64define double @f5(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000065; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000066; CHECK-NOT: clhhsi
67; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000068 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000069 %ext = zext i16 %val to i64
70 %cond = icmp ult i64 %ext, 65536
71 %res = select i1 %cond, double %a, double %b
72 ret double %res
73}
74
75; When using unsigned comparison with sign extension, equality with values
76; in the range [32768, MAX-32769] is impossible, and ordered comparisons with
77; those values are effectively sign tests. Since such comparisons are
78; unlikely to occur in practice, we don't bother optimizing the second case,
79; and simply ignore CLHHSI for this range. First check the low end of the
80; range.
81define double @f6(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000082; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000083; CHECK-NOT: clhhsi
84; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000085 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000086 %ext = sext i16 %val to i64
87 %cond = icmp ult i64 %ext, 32768
88 %res = select i1 %cond, double %a, double %b
89 ret double %res
90}
91
92; ...and then the high end.
93define double @f7(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +000094; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000095; CHECK-NOT: clhhsi
96; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +000097 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000098 %ext = sext i16 %val to i64
99 %cond = icmp ult i64 %ext, -32769
100 %res = select i1 %cond, double %a, double %b
101 ret double %res
102}
103
104; Check signed comparison near the low end of the CLHHSI range, using zero
105; extension. This is equivalent to unsigned comparison.
106define double @f8(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000107; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000108; CHECK: clhhsi 0(%r2), 1
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000109; CHECK-NEXT: bhr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000110; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000111 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000112 %ext = zext i16 %val to i64
113 %cond = icmp sgt i64 %ext, 1
114 %res = select i1 %cond, double %a, double %b
115 ret double %res
116}
117
118; Check signed comparison near the low end of the CLHHSI range, using sign
119; extension. This should use CHHSI instead.
120define double @f9(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000121; CHECK-LABEL: f9:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000122; CHECK: chhsi 0(%r2), 1
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000123; CHECK-NEXT: bhr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000124; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000125 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000126 %ext = sext i16 %val to i64
127 %cond = icmp sgt i64 %ext, 1
128 %res = select i1 %cond, double %a, double %b
129 ret double %res
130}
131
132; Check signed comparison near the high end of the CLHHSI range, using zero
133; extension. This is equivalent to unsigned comparison.
134define double @f10(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000135; CHECK-LABEL: f10:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000136; CHECK: clhhsi 0(%r2), 65534
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000137; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000138; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000139 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000140 %ext = zext i16 %val to i64
141 %cond = icmp slt i64 %ext, 65534
142 %res = select i1 %cond, double %a, double %b
143 ret double %res
144}
145
146; Check signed comparison near the high end of the CLHHSI range, using sign
147; extension. This should use CHHSI instead.
148define double @f11(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000149; CHECK-LABEL: f11:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000150; CHECK: chhsi 0(%r2), -2
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000151; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000152; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000153 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000154 %ext = sext i16 %val to i64
155 %cond = icmp slt i64 %ext, -2
156 %res = select i1 %cond, double %a, double %b
157 ret double %res
158}
159
160; Check signed comparison above the high end of the CLHHSI range, using zero
161; extension. The condition is always true.
162define double @f12(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000163; CHECK-LABEL: f12:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000164; CHECK-NOT: cli
165; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000166 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000167 %ext = zext i16 %val to i64
168 %cond = icmp slt i64 %ext, 65536
169 %res = select i1 %cond, double %a, double %b
170 ret double %res
171}
172
173; Check signed comparison near the high end of the CHHSI range, using sign
174; extension.
175define double @f13(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000176; CHECK-LABEL: f13:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000177; CHECK: chhsi 0(%r2), 32766
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000178; CHECK-NEXT: blr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000179; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000180 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000181 %ext = sext i16 %val to i64
182 %cond = icmp slt i64 %ext, 32766
183 %res = select i1 %cond, double %a, double %b
184 ret double %res
185}
186
187; Check signed comparison above the high end of the CHHSI range, using sign
188; extension. This condition is always true.
189define double @f14(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000190; CHECK-LABEL: f14:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000191; CHECK-NOT: chhsi
192; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000193 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000194 %ext = sext i16 %val to i64
195 %cond = icmp slt i64 %ext, 32768
196 %res = select i1 %cond, double %a, double %b
197 ret double %res
198}
199
200; Check signed comparison near the low end of the CHHSI range, using sign
201; extension.
202define double @f15(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000203; CHECK-LABEL: f15:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000204; CHECK: chhsi 0(%r2), -32767
Ulrich Weigand2eb027d2016-04-07 16:11:44 +0000205; CHECK-NEXT: bhr %r14
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000206; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000207 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000208 %ext = sext i16 %val to i64
209 %cond = icmp sgt i64 %ext, -32767
210 %res = select i1 %cond, double %a, double %b
211 ret double %res
212}
213
214; Check signed comparison below the low end of the CHHSI range, using sign
215; extension. This condition is always true.
216define double @f16(double %a, double %b, i16 *%ptr) {
Stephen Lind24ab202013-07-14 06:24:09 +0000217; CHECK-LABEL: f16:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000218; CHECK-NOT: chhsi
219; CHECK: br %r14
David Blaikiea79ac142015-02-27 21:17:42 +0000220 %val = load i16 , i16 *%ptr
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000221 %ext = sext i16 %val to i64
222 %cond = icmp sgt i64 %ext, -32769
223 %res = select i1 %cond, double %a, double %b
224 ret double %res
225}