blob: 8fb0e7c41a425bc1e4c9ce3fde4c64032e1d9f05 [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) {
7; CHECK: 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
16; Check comparisons with 1.
17define double @f2(double %a, double %b, i32 %i1) {
18; CHECK: f2:
Richard Sandiforde1d9f002013-05-29 11:58:52 +000019; CHECK: cijl %r2, 1
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000020; CHECK: ldr %f0, %f2
21; CHECK: br %r14
22 %cond = icmp slt i32 %i1, 1
23 %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) {
29; CHECK: 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) {
40; CHECK: f4:
41; 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) {
52; CHECK: 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) {
64; CHECK: 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) {
76; CHECK: 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) {
88; CHECK: 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) {
100; CHECK: f9:
101; 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) {
111; CHECK: f10:
112; 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) {
122; CHECK: f11:
123; 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) {
134; CHECK: 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) {
146; CHECK: 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) {
158; CHECK: 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) {
170; CHECK: 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}