blob: 64386f05d1e935f20e33735fe1ebefe6c76705a7 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test 64-bit signed comparisons in which the second operand is 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, i64 %i1) {
7; CHECK: f1:
8; CHECK: cghi %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 i64 %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, i64 %i1) {
19; CHECK: f2:
20; CHECK: cghi %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 i64 %i1, 1
25 %res = select i1 %cond, double %a, double %b
26 ret double %res
27}
28
29; Check the high end of the CGHI range.
30define double @f3(double %a, double %b, i64 %i1) {
31; CHECK: f3:
32; CHECK: cghi %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 i64 %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 CGFI.
42define double @f4(double %a, double %b, i64 %i1) {
43; CHECK: f4:
44; CHECK: cgfi %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 i64 %i1, 32768
49 %res = select i1 %cond, double %a, double %b
50 ret double %res
51}
52
53; Check the high end of the CGFI range.
54define double @f5(double %a, double %b, i64 %i1) {
55; CHECK: f5:
56; CHECK: cgfi %r2, 2147483647
Richard Sandiford586f4172013-05-21 08:53:17 +000057; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000058; CHECK: ldr %f0, %f2
59; CHECK: br %r14
60 %cond = icmp slt i64 %i1, 2147483647
61 %res = select i1 %cond, double %a, double %b
62 ret double %res
63}
64
65; Check the next value up, which must use register comparison.
66define double @f6(double %a, double %b, i64 %i1) {
67; CHECK: f6:
Richard Sandiford0fb90ab2013-05-28 10:41:11 +000068; CHECK: cgrjl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000069; CHECK: ldr %f0, %f2
70; CHECK: br %r14
71 %cond = icmp slt i64 %i1, 2147483648
72 %res = select i1 %cond, double %a, double %b
73 ret double %res
74}
75
76; Check the high end of the negative CGHI range.
77define double @f7(double %a, double %b, i64 %i1) {
78; CHECK: f7:
79; CHECK: cghi %r2, -1
Richard Sandiford586f4172013-05-21 08:53:17 +000080; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000081; CHECK: ldr %f0, %f2
82; CHECK: br %r14
83 %cond = icmp slt i64 %i1, -1
84 %res = select i1 %cond, double %a, double %b
85 ret double %res
86}
87
88; Check the low end of the CGHI range.
89define double @f8(double %a, double %b, i64 %i1) {
90; CHECK: f8:
91; CHECK: cghi %r2, -32768
Richard Sandiford586f4172013-05-21 08:53:17 +000092; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000093; CHECK: ldr %f0, %f2
94; CHECK: br %r14
95 %cond = icmp slt i64 %i1, -32768
96 %res = select i1 %cond, double %a, double %b
97 ret double %res
98}
99
100; Check the next value down, which must use CGFI instead.
101define double @f9(double %a, double %b, i64 %i1) {
102; CHECK: f9:
103; CHECK: cgfi %r2, -32769
Richard Sandiford586f4172013-05-21 08:53:17 +0000104; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000105; CHECK: ldr %f0, %f2
106; CHECK: br %r14
107 %cond = icmp slt i64 %i1, -32769
108 %res = select i1 %cond, double %a, double %b
109 ret double %res
110}
111
112; Check the low end of the CGFI range.
113define double @f10(double %a, double %b, i64 %i1) {
114; CHECK: f10:
115; CHECK: cgfi %r2, -2147483648
Richard Sandiford586f4172013-05-21 08:53:17 +0000116; CHECK-NEXT: jl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000117; CHECK: ldr %f0, %f2
118; CHECK: br %r14
119 %cond = icmp slt i64 %i1, -2147483648
120 %res = select i1 %cond, double %a, double %b
121 ret double %res
122}
123
124; Check the next value down, which must use register comparison.
125define double @f11(double %a, double %b, i64 %i1) {
126; CHECK: f11:
Richard Sandiford0fb90ab2013-05-28 10:41:11 +0000127; CHECK: cgrjl
Ulrich Weigand9e3577f2013-05-06 16:17:29 +0000128; CHECK: ldr %f0, %f2
129; CHECK: br %r14
130 %cond = icmp slt i64 %i1, -2147483649
131 %res = select i1 %cond, double %a, double %b
132 ret double %res
133}