[SystemZ] Add CodeGen test cases
[oota-llvm.git] / test / CodeGen / SystemZ / int-cmp-13.ll
1 ; Test 64-bit equality 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.
6 define double @f1(double %a, double %b, i64 %i1) {
7 ; CHECK: f1:
8 ; CHECK: cghi %r2, 0
9 ; CHECK-NEXT: j{{g?}}e
10 ; CHECK: ldr %f0, %f2
11 ; CHECK: br %r14
12   %cond = icmp eq i64 %i1, 0
13   %res = select i1 %cond, double %a, double %b
14   ret double %res
15 }
16
17 ; Check the high end of the CGHI range.
18 define double @f2(double %a, double %b, i64 %i1) {
19 ; CHECK: f2:
20 ; CHECK: cghi %r2, 32767
21 ; CHECK-NEXT: j{{g?}}e
22 ; CHECK: ldr %f0, %f2
23 ; CHECK: br %r14
24   %cond = icmp eq i64 %i1, 32767
25   %res = select i1 %cond, double %a, double %b
26   ret double %res
27 }
28
29 ; Check the next value up, which must use CGFI.
30 define double @f3(double %a, double %b, i64 %i1) {
31 ; CHECK: f3:
32 ; CHECK: cgfi %r2, 32768
33 ; CHECK-NEXT: j{{g?}}e
34 ; CHECK: ldr %f0, %f2
35 ; CHECK: br %r14
36   %cond = icmp eq i64 %i1, 32768
37   %res = select i1 %cond, double %a, double %b
38   ret double %res
39 }
40
41 ; Check the high end of the CGFI range.
42 define double @f4(double %a, double %b, i64 %i1) {
43 ; CHECK: f4:
44 ; CHECK: cgfi %r2, 2147483647
45 ; CHECK-NEXT: j{{g?}}e
46 ; CHECK: ldr %f0, %f2
47 ; CHECK: br %r14
48   %cond = icmp eq i64 %i1, 2147483647
49   %res = select i1 %cond, double %a, double %b
50   ret double %res
51 }
52
53 ; Check the next value up, which should use CLGFI instead.
54 define double @f5(double %a, double %b, i64 %i1) {
55 ; CHECK: f5:
56 ; CHECK: clgfi %r2, 2147483648
57 ; CHECK-NEXT: j{{g?}}e
58 ; CHECK: ldr %f0, %f2
59 ; CHECK: br %r14
60   %cond = icmp eq i64 %i1, 2147483648
61   %res = select i1 %cond, double %a, double %b
62   ret double %res
63 }
64
65 ; Check the high end of the CLGFI range.
66 define double @f6(double %a, double %b, i64 %i1) {
67 ; CHECK: f6:
68 ; CHECK: clgfi %r2, 4294967295
69 ; CHECK-NEXT: j{{g?}}e
70 ; CHECK: ldr %f0, %f2
71 ; CHECK: br %r14
72   %cond = icmp eq i64 %i1, 4294967295
73   %res = select i1 %cond, double %a, double %b
74   ret double %res
75 }
76
77 ; Check the next value up, which must use a register comparison.
78 define double @f7(double %a, double %b, i64 %i1) {
79 ; CHECK: f7:
80 ; CHECK: cgr %r2,
81 ; CHECK-NEXT: j{{g?}}e
82 ; CHECK: ldr %f0, %f2
83 ; CHECK: br %r14
84   %cond = icmp eq i64 %i1, 4294967296
85   %res = select i1 %cond, double %a, double %b
86   ret double %res
87 }
88
89 ; Check the high end of the negative CGHI range.
90 define double @f8(double %a, double %b, i64 %i1) {
91 ; CHECK: f8:
92 ; CHECK: cghi %r2, -1
93 ; CHECK-NEXT: j{{g?}}e
94 ; CHECK: ldr %f0, %f2
95 ; CHECK: br %r14
96   %cond = icmp eq i64 %i1, -1
97   %res = select i1 %cond, double %a, double %b
98   ret double %res
99 }
100
101 ; Check the low end of the CGHI range.
102 define double @f9(double %a, double %b, i64 %i1) {
103 ; CHECK: f9:
104 ; CHECK: cghi %r2, -32768
105 ; CHECK-NEXT: j{{g?}}e
106 ; CHECK: ldr %f0, %f2
107 ; CHECK: br %r14
108   %cond = icmp eq i64 %i1, -32768
109   %res = select i1 %cond, double %a, double %b
110   ret double %res
111 }
112
113 ; Check the next value down, which must use CGFI instead.
114 define double @f10(double %a, double %b, i64 %i1) {
115 ; CHECK: f10:
116 ; CHECK: cgfi %r2, -32769
117 ; CHECK-NEXT: j{{g?}}e
118 ; CHECK: ldr %f0, %f2
119 ; CHECK: br %r14
120   %cond = icmp eq i64 %i1, -32769
121   %res = select i1 %cond, double %a, double %b
122   ret double %res
123 }
124
125 ; Check the low end of the CGFI range.
126 define double @f11(double %a, double %b, i64 %i1) {
127 ; CHECK: f11:
128 ; CHECK: cgfi %r2, -2147483648
129 ; CHECK-NEXT: j{{g?}}e
130 ; CHECK: ldr %f0, %f2
131 ; CHECK: br %r14
132   %cond = icmp eq i64 %i1, -2147483648
133   %res = select i1 %cond, double %a, double %b
134   ret double %res
135 }
136
137 ; Check the next value down, which must use register comparison.
138 define double @f12(double %a, double %b, i64 %i1) {
139 ; CHECK: f12:
140 ; CHECK: cgr
141 ; CHECK-NEXT: j{{g?}}e
142 ; CHECK: ldr %f0, %f2
143 ; CHECK: br %r14
144   %cond = icmp eq i64 %i1, -2147483649
145   %res = select i1 %cond, double %a, double %b
146   ret double %res
147 }