blob: 06ebee250bcb166de8282c25fac6f71381067d71 [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:
8; CHECK: chi %r2, 0
Richard Sandiford586f4172013-05-21 08:53:17 +00009; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000010; CHECK: ldr %f0, %f2
11; CHECK: br %r14
12 %cond = icmp slt i32 %i1, 0
13 %res = select i1 %cond, double %a, double %b
14 ret double %res
15}
16
17; Check comparisons with 1.
18define double @f2(double %a, double %b, i32 %i1) {
19; CHECK: f2:
20; CHECK: chi %r2, 1
Richard Sandiford586f4172013-05-21 08:53:17 +000021; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000022; CHECK: ldr %f0, %f2
23; CHECK: br %r14
24 %cond = icmp slt i32 %i1, 1
25 %res = select i1 %cond, double %a, double %b
26 ret double %res
27}
28
29; Check the high end of the CHI range.
30define double @f3(double %a, double %b, i32 %i1) {
31; CHECK: f3:
32; CHECK: chi %r2, 32767
Richard Sandiford586f4172013-05-21 08:53:17 +000033; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000034; CHECK: ldr %f0, %f2
35; CHECK: br %r14
36 %cond = icmp slt i32 %i1, 32767
37 %res = select i1 %cond, double %a, double %b
38 ret double %res
39}
40
41; Check the next value up, which must use CFI.
42define double @f4(double %a, double %b, i32 %i1) {
43; CHECK: f4:
44; CHECK: cfi %r2, 32768
Richard Sandiford586f4172013-05-21 08:53:17 +000045; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000046; CHECK: ldr %f0, %f2
47; CHECK: br %r14
48 %cond = icmp slt i32 %i1, 32768
49 %res = select i1 %cond, double %a, double %b
50 ret double %res
51}
52
53; Check the high end of the signed 32-bit range.
54define double @f5(double %a, double %b, i32 %i1) {
55; CHECK: f5:
56; CHECK: cfi %r2, 2147483647
Richard Sandiford586f4172013-05-21 08:53:17 +000057; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000058; CHECK: ldr %f0, %f2
59; CHECK: br %r14
60 %cond = icmp eq i32 %i1, 2147483647
61 %res = select i1 %cond, double %a, double %b
62 ret double %res
63}
64
65; Check the next value up, which should be treated as a negative value.
66define double @f6(double %a, double %b, i32 %i1) {
67; CHECK: f6:
68; CHECK: cfi %r2, -2147483648
Richard Sandiford586f4172013-05-21 08:53:17 +000069; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000070; CHECK: ldr %f0, %f2
71; CHECK: br %r14
72 %cond = icmp eq i32 %i1, 2147483648
73 %res = select i1 %cond, double %a, double %b
74 ret double %res
75}
76
77; Check the high end of the negative CHI range.
78define double @f7(double %a, double %b, i32 %i1) {
79; CHECK: f7:
80; CHECK: chi %r2, -1
Richard Sandiford586f4172013-05-21 08:53:17 +000081; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000082; CHECK: ldr %f0, %f2
83; CHECK: br %r14
84 %cond = icmp slt i32 %i1, -1
85 %res = select i1 %cond, double %a, double %b
86 ret double %res
87}
88
89; Check the low end of the CHI range.
90define double @f8(double %a, double %b, i32 %i1) {
91; CHECK: f8:
92; CHECK: chi %r2, -32768
Richard Sandiford586f4172013-05-21 08:53:17 +000093; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000094; CHECK: ldr %f0, %f2
95; CHECK: br %r14
96 %cond = icmp slt i32 %i1, -32768
97 %res = select i1 %cond, double %a, double %b
98 ret double %res
99}
100
101; Check the next value down, which must use CFI instead.
102define double @f9(double %a, double %b, i32 %i1) {
103; CHECK: f9:
104; CHECK: cfi %r2, -32769
Richard Sandiford586f4172013-05-21 08:53:17 +0000105; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000106; CHECK: ldr %f0, %f2
107; CHECK: br %r14
108 %cond = icmp slt i32 %i1, -32769
109 %res = select i1 %cond, double %a, double %b
110 ret double %res
111}
112
113; Check the low end of the signed 32-bit range.
114define double @f10(double %a, double %b, i32 %i1) {
115; CHECK: f10:
116; CHECK: cfi %r2, -2147483648
Richard Sandiford586f4172013-05-21 08:53:17 +0000117; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000118; CHECK: ldr %f0, %f2
119; CHECK: br %r14
120 %cond = icmp eq i32 %i1, -2147483648
121 %res = select i1 %cond, double %a, double %b
122 ret double %res
123}
124
125; Check the next value down, which should be treated as a positive value.
126define double @f11(double %a, double %b, i32 %i1) {
127; CHECK: f11:
128; CHECK: cfi %r2, 2147483647
Richard Sandiford586f4172013-05-21 08:53:17 +0000129; CHECK-NEXT: je
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000130; CHECK: ldr %f0, %f2
131; CHECK: br %r14
132 %cond = icmp eq i32 %i1, -2147483649
133 %res = select i1 %cond, double %a, double %b
134 ret double %res
135}