blob: 0eb8c6688c0cc6d55581809cc65bb8e02715163b [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 32-bit signed comparison in which the second operand is 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, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +00007; CHECK-LABEL: f1:
Richard Sandiforde1d9f002013-05-29 11:58:52 +00008; CHECK: cijl %r2, 0
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00009; CHECK: ldr %f0, %f2
10; CHECK: br %r14
11 %cond = icmp slt i32 %i1, 0
12 %res = select i1 %cond, double %a, double %b
13 ret double %res
14}
15
Richard Sandiforda0757082013-08-01 10:29:45 +000016; Check comparisons with 2.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000017define double @f2(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +000018; CHECK-LABEL: f2:
Richard Sandiforda0757082013-08-01 10:29:45 +000019; CHECK: cijl %r2, 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000020; CHECK: ldr %f0, %f2
21; CHECK: br %r14
Richard Sandiforda0757082013-08-01 10:29:45 +000022 %cond = icmp slt i32 %i1, 2
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000023 %res = select i1 %cond, double %a, double %b
24 ret double %res
25}
26
Richard Sandiforde1d9f002013-05-29 11:58:52 +000027; Check the high end of the CIJ range.
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000028define double @f3(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +000029; CHECK-LABEL: f3:
Richard Sandiforde1d9f002013-05-29 11:58:52 +000030; CHECK: cijl %r2, 127
31; CHECK: ldr %f0, %f2
32; CHECK: br %r14
33 %cond = icmp slt i32 %i1, 127
34 %res = select i1 %cond, double %a, double %b
35 ret double %res
36}
37
38; Check the next value up, which must use CHI instead.
39define double @f4(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +000040; CHECK-LABEL: f4:
Richard Sandiforde1d9f002013-05-29 11:58:52 +000041; CHECK: chi %r2, 128
42; CHECK-NEXT: jl
43; CHECK: ldr %f0, %f2
44; CHECK: br %r14
45 %cond = icmp slt i32 %i1, 128
46 %res = select i1 %cond, double %a, double %b
47 ret double %res
48}
49
50; Check the high end of the CHI range.
51define double @f5(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +000052; CHECK-LABEL: f5:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000053; CHECK: chi %r2, 32767
Richard Sandiford586f4172013-05-21 08:53:17 +000054; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000055; CHECK: ldr %f0, %f2
56; CHECK: br %r14
57 %cond = icmp slt i32 %i1, 32767
58 %res = select i1 %cond, double %a, double %b
59 ret double %res
60}
61
62; Check the next value up, which must use CFI.
Richard Sandiforde1d9f002013-05-29 11:58:52 +000063define double @f6(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +000064; CHECK-LABEL: f6:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000065; CHECK: cfi %r2, 32768
Richard Sandiford586f4172013-05-21 08:53:17 +000066; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000067; CHECK: ldr %f0, %f2
68; CHECK: br %r14
69 %cond = icmp slt i32 %i1, 32768
70 %res = select i1 %cond, double %a, double %b
71 ret double %res
72}
73
74; Check the high end of the signed 32-bit range.
Richard Sandiforde1d9f002013-05-29 11:58:52 +000075define double @f7(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +000076; CHECK-LABEL: f7:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000077; CHECK: cfi %r2, 2147483647
Richard Sandiford586f4172013-05-21 08:53:17 +000078; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000079; CHECK: ldr %f0, %f2
80; CHECK: br %r14
81 %cond = icmp eq i32 %i1, 2147483647
82 %res = select i1 %cond, double %a, double %b
83 ret double %res
84}
85
86; Check the next value up, which should be treated as a negative value.
Richard Sandiforde1d9f002013-05-29 11:58:52 +000087define double @f8(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +000088; CHECK-LABEL: f8:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000089; CHECK: cfi %r2, -2147483648
Richard Sandiford586f4172013-05-21 08:53:17 +000090; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000091; CHECK: ldr %f0, %f2
92; CHECK: br %r14
93 %cond = icmp eq i32 %i1, 2147483648
94 %res = select i1 %cond, double %a, double %b
95 ret double %res
96}
97
Richard Sandiforde1d9f002013-05-29 11:58:52 +000098; Check the high end of the negative CIJ range.
99define double @f9(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +0000100; CHECK-LABEL: f9:
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000101; CHECK: cijl %r2, -1
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000102; CHECK: ldr %f0, %f2
103; CHECK: br %r14
104 %cond = icmp slt i32 %i1, -1
105 %res = select i1 %cond, double %a, double %b
106 ret double %res
107}
108
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000109; Check the low end of the CIJ range.
110define double @f10(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +0000111; CHECK-LABEL: f10:
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000112; CHECK: cijl %r2, -128
113; CHECK: ldr %f0, %f2
114; CHECK: br %r14
115 %cond = icmp slt i32 %i1, -128
116 %res = select i1 %cond, double %a, double %b
117 ret double %res
118}
119
120; Check the next value down, which must use CHI instead.
121define double @f11(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +0000122; CHECK-LABEL: f11:
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000123; CHECK: chi %r2, -129
124; CHECK-NEXT: jl
125; CHECK: ldr %f0, %f2
126; CHECK: br %r14
127 %cond = icmp slt i32 %i1, -129
128 %res = select i1 %cond, double %a, double %b
129 ret double %res
130}
131
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000132; Check the low end of the CHI range.
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000133define double @f12(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +0000134; CHECK-LABEL: f12:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000135; CHECK: chi %r2, -32768
Richard Sandiford586f4172013-05-21 08:53:17 +0000136; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000137; CHECK: ldr %f0, %f2
138; CHECK: br %r14
139 %cond = icmp slt i32 %i1, -32768
140 %res = select i1 %cond, double %a, double %b
141 ret double %res
142}
143
144; Check the next value down, which must use CFI instead.
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000145define double @f13(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +0000146; CHECK-LABEL: f13:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000147; CHECK: cfi %r2, -32769
Richard Sandiford586f4172013-05-21 08:53:17 +0000148; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000149; CHECK: ldr %f0, %f2
150; CHECK: br %r14
151 %cond = icmp slt i32 %i1, -32769
152 %res = select i1 %cond, double %a, double %b
153 ret double %res
154}
155
156; Check the low end of the signed 32-bit range.
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000157define double @f14(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +0000158; CHECK-LABEL: f14:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000159; CHECK: cfi %r2, -2147483648
Richard Sandiford586f4172013-05-21 08:53:17 +0000160; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000161; CHECK: ldr %f0, %f2
162; CHECK: br %r14
163 %cond = icmp eq i32 %i1, -2147483648
164 %res = select i1 %cond, double %a, double %b
165 ret double %res
166}
167
168; Check the next value down, which should be treated as a positive value.
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000169define double @f15(double %a, double %b, i32 %i1) {
Stephen Lind24ab202013-07-14 06:24:09 +0000170; CHECK-LABEL: f15:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000171; CHECK: cfi %r2, 2147483647
Richard Sandiford586f4172013-05-21 08:53:17 +0000172; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000173; CHECK: ldr %f0, %f2
174; CHECK: br %r14
175 %cond = icmp eq i32 %i1, -2147483649
176 %res = select i1 %cond, double %a, double %b
177 ret double %res
178}
Richard Sandiforda0757082013-08-01 10:29:45 +0000179
180; Check that < 1 becomes <= 0.
181define double @f16(double %a, double %b, i32 %i1) {
182; CHECK-LABEL: f16:
183; CHECK: cijle %r2, 0
184; CHECK: ldr %f0, %f2
185; CHECK: br %r14
186 %cond = icmp slt i32 %i1, 1
187 %res = select i1 %cond, double %a, double %b
188 ret double %res
189}
190
191; Check that >= 1 becomes > 0.
192define double @f17(double %a, double %b, i32 %i1) {
193; CHECK-LABEL: f17:
194; CHECK: cijh %r2, 0
195; CHECK: ldr %f0, %f2
196; CHECK: br %r14
197 %cond = icmp sge i32 %i1, 1
198 %res = select i1 %cond, double %a, double %b
199 ret double %res
200}
201
202; Check that > -1 becomes >= 0.
203define double @f18(double %a, double %b, i32 %i1) {
204; CHECK-LABEL: f18:
205; CHECK: cijhe %r2, 0
206; CHECK: ldr %f0, %f2
207; CHECK: br %r14
208 %cond = icmp sgt i32 %i1, -1
209 %res = select i1 %cond, double %a, double %b
210 ret double %res
211}
212
213; Check that <= -1 becomes < 0.
214define double @f19(double %a, double %b, i32 %i1) {
215; CHECK-LABEL: f19:
216; CHECK: cijl %r2, 0
217; CHECK: ldr %f0, %f2
218; CHECK: br %r14
219 %cond = icmp sle i32 %i1, -1
220 %res = select i1 %cond, double %a, double %b
221 ret double %res
222}