Skip to content

Commit 0fef7b8

Browse files
committed
Precommit tests
1 parent 9b7fd00 commit 0fef7b8

File tree

5 files changed

+767
-0
lines changed

5 files changed

+767
-0
lines changed
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
2+
; RUN: cat %S/floating-point-constants.ll %s | opt -passes=instcombine -S | FileCheck %s
3+
4+
declare double @nextafter(double, double) #0
5+
declare float @nextafterf(float, float) #0
6+
7+
attributes #0 = { willreturn memory(errnomem: write) }
8+
9+
define double @nextafter_up_direction() {
10+
; CHECK-LABEL: define double @nextafter_up_direction() {
11+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 1.000000e+00, double 2.000000e+00)
12+
; CHECK-NEXT: ret double [[NEXT]]
13+
;
14+
%next = call double @nextafter(double 1.0, double 2.0)
15+
ret double %next
16+
}
17+
18+
define float @nextafterf_up_direction() {
19+
; CHECK-LABEL: define float @nextafterf_up_direction() {
20+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 1.000000e+00, float 2.000000e+00)
21+
; CHECK-NEXT: ret float [[NEXT]]
22+
;
23+
%next = call float @nextafterf(float 1.0, float 2.0)
24+
ret float %next
25+
}
26+
27+
define double @nextafter_down_direction() {
28+
; CHECK-LABEL: define double @nextafter_down_direction() {
29+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 1.000000e+00, double 0.000000e+00)
30+
; CHECK-NEXT: ret double [[NEXT]]
31+
;
32+
%next = call double @nextafter(double 1.0, double 0.0)
33+
ret double %next
34+
}
35+
36+
define float @nextafterf_down_direction() {
37+
; CHECK-LABEL: define float @nextafterf_down_direction() {
38+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 1.000000e+00, float 0.000000e+00)
39+
; CHECK-NEXT: ret float [[NEXT]]
40+
;
41+
%next = call float @nextafterf(float 1.0, float 0.0)
42+
ret float %next
43+
}
44+
45+
define double @nextafter_equal_args() {
46+
; CHECK-LABEL: define double @nextafter_equal_args() {
47+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 1.000000e+00, double 1.000000e+00)
48+
; CHECK-NEXT: ret double [[NEXT]]
49+
;
50+
%next = call double @nextafter(double 1.0, double 1.0)
51+
ret double %next
52+
}
53+
54+
define float @nextafterf_equal_args() {
55+
; CHECK-LABEL: define float @nextafterf_equal_args() {
56+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 1.000000e+00, float 1.000000e+00)
57+
; CHECK-NEXT: ret float [[NEXT]]
58+
;
59+
%next = call float @nextafterf(float 1.0, float 1.0)
60+
ret float %next
61+
}
62+
63+
define double @nextafter_nan_with_payload() {
64+
; CHECK-LABEL: define double @nextafter_nan_with_payload() {
65+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 0x7FF8000000000001, double 1.000000e+00)
66+
; CHECK-NEXT: ret double [[NEXT]]
67+
;
68+
%nan = load double, double* @dbl_nan
69+
%tmp1 = bitcast double %nan to i64
70+
%tmp2 = or i64 %tmp1, 1
71+
%nan_with_payload = bitcast i64 %tmp2 to double
72+
%next = call double @nextafter(double %nan_with_payload, double 1.0)
73+
ret double %next
74+
75+
}
76+
77+
define float @nextafterf_nan_with_payload() {
78+
; CHECK-LABEL: define float @nextafterf_nan_with_payload() {
79+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0x7FF8000020000000, float 1.000000e+00)
80+
; CHECK-NEXT: ret float [[NEXT]]
81+
;
82+
%nan = load float, float* @flt_nan
83+
%tmp1 = bitcast float %nan to i32
84+
%tmp2 = or i32 %tmp1, 1
85+
%nan_with_payload = bitcast i32 %tmp2 to float
86+
%next = call float @nextafterf(float %nan_with_payload, float 1.0)
87+
ret float %next
88+
}
89+
90+
define double @nextafter_pos_overflow () {
91+
; CHECK-LABEL: define double @nextafter_pos_overflow() {
92+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 0x7FEFFFFFFFFFFFFF, double 0x7FF0000000000000)
93+
; CHECK-NEXT: ret double [[NEXT]]
94+
;
95+
%arg1 = load double, double* @dbl_pos_max
96+
%arg2 = load double, double* @dbl_pos_infinity
97+
%next = call double @nextafter(double %arg1, double %arg2)
98+
ret double %next
99+
}
100+
101+
define float @nextafterf_pos_overflow() {
102+
; CHECK-LABEL: define float @nextafterf_pos_overflow() {
103+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0x47EFFFFFE0000000, float 0x7FF0000000000000)
104+
; CHECK-NEXT: ret float [[NEXT]]
105+
;
106+
%arg1 = load float, float* @flt_pos_max
107+
%arg2 = load float, float* @flt_pos_infinity
108+
%next = call float @nextafterf(float %arg1, float %arg2)
109+
ret float %next
110+
}
111+
112+
define double @nextafter_neg_overflow() {
113+
; CHECK-LABEL: define double @nextafter_neg_overflow() {
114+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 0xFFEFFFFFFFFFFFFF, double 0xFFF0000000000000)
115+
; CHECK-NEXT: ret double [[NEXT]]
116+
;
117+
%arg1 = load double, double* @dbl_neg_max
118+
%arg2 = load double, double* @dbl_neg_infinity
119+
%next = call double @nextafter(double %arg1, double %arg2)
120+
ret double %next
121+
}
122+
123+
define float @nextafterf_neg_overflow() {
124+
; CHECK-LABEL: define float @nextafterf_neg_overflow() {
125+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0xC7EFFFFFE0000000, float 0xFFF0000000000000)
126+
; CHECK-NEXT: ret float [[NEXT]]
127+
;
128+
%arg1 = load float, float* @flt_neg_max
129+
%arg2 = load float, float* @flt_neg_infinity
130+
%next = call float @nextafterf(float %arg1, float %arg2)
131+
ret float %next
132+
}
133+
134+
define double @nextafter_zero_from_above() {
135+
; CHECK-LABEL: define double @nextafter_zero_from_above() {
136+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 4.940660e-324, double 0.000000e+00)
137+
; CHECK-NEXT: ret double [[NEXT]]
138+
;
139+
%arg = load double, double* @dbl_pos_min_subnormal
140+
%next = call double @nextafter(double %arg, double 0.0)
141+
ret double %next
142+
}
143+
144+
define float @nextafterf_zero_from_above() {
145+
; CHECK-LABEL: define float @nextafterf_zero_from_above() {
146+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0x36A0000000000000, float 0.000000e+00)
147+
; CHECK-NEXT: ret float [[NEXT]]
148+
;
149+
%arg = load float, float* @flt_pos_min_subnormal
150+
%next = call float @nextafterf(float %arg, float 0.0)
151+
ret float %next
152+
}
153+
154+
define double @nextafter_zero_from_below() {
155+
; CHECK-LABEL: define double @nextafter_zero_from_below() {
156+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double -4.940660e-324, double 0.000000e+00)
157+
; CHECK-NEXT: ret double [[NEXT]]
158+
;
159+
%arg = load double, double* @dbl_neg_min_subnormal
160+
%next = call double @nextafter(double %arg, double 0.0)
161+
ret double %next
162+
}
163+
164+
define float @nextafterf_zero_from_below() {
165+
; CHECK-LABEL: define float @nextafterf_zero_from_below() {
166+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0xB6A0000000000000, float 0.000000e+00)
167+
; CHECK-NEXT: ret float [[NEXT]]
168+
;
169+
%arg = load float, float* @flt_neg_min_subnormal
170+
%next = call float @nextafterf(float %arg, float 0.0)
171+
ret float %next
172+
}
173+
174+
define double @nextafter_subnormal() {
175+
; CHECK-LABEL: define double @nextafter_subnormal() {
176+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 4.940660e-324, double 0x7FF0000000000000)
177+
; CHECK-NEXT: ret double [[NEXT]]
178+
;
179+
%subnormal = load double, double* @dbl_pos_min_subnormal
180+
%infinity = load double, double* @dbl_pos_infinity
181+
%next = call double @nextafter(double %subnormal, double %infinity)
182+
ret double %next
183+
}
184+
185+
define float @nextafterf_subnormal() {
186+
; CHECK-LABEL: define float @nextafterf_subnormal() {
187+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0x36A0000000000000, float 0x7FF0000000000000)
188+
; CHECK-NEXT: ret float [[NEXT]]
189+
;
190+
%subnormal = load float, float* @flt_pos_min_subnormal
191+
%infinity = load float, float* @flt_pos_infinity
192+
%next = call float @nextafterf(float %subnormal, float %infinity)
193+
ret float %next
194+
}
195+
196+
define double @nextafter_poison() {
197+
; CHECK-LABEL: define double @nextafter_poison() {
198+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double poison, double 1.000000e+00)
199+
; CHECK-NEXT: ret double [[NEXT]]
200+
;
201+
%next = call double @nextafter(double poison, double 1.0)
202+
ret double %next
203+
}
204+
205+
define double @nextafterf_poison() {
206+
; CHECK-LABEL: define double @nextafterf_poison() {
207+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafterf(float poison, float 1.000000e+00)
208+
; CHECK-NEXT: ret double [[NEXT]]
209+
;
210+
%next = call double @nextafterf(float poison, float 1.0)
211+
ret double %next
212+
}
213+
214+
define double @nextafter_subnormal_readnone() {
215+
; CHECK-LABEL: define double @nextafter_subnormal_readnone() {
216+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 4.940660e-324, double 0x7FF0000000000000) #[[ATTR1:[0-9]+]]
217+
; CHECK-NEXT: ret double [[NEXT]]
218+
;
219+
%subnormal = load double, double* @dbl_pos_min_subnormal
220+
%infinity = load double, double* @dbl_pos_infinity
221+
%next = call double @nextafter(double %subnormal, double %infinity) readnone
222+
ret double %next
223+
}
224+
225+
define float @nextafterf_subnormal_readnone() {
226+
; CHECK-LABEL: define float @nextafterf_subnormal_readnone() {
227+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0x36A0000000000000, float 0x7FF0000000000000) #[[ATTR1]]
228+
; CHECK-NEXT: ret float [[NEXT]]
229+
;
230+
%subnormal = load float, float* @flt_pos_min_subnormal
231+
%infinity = load float, float* @flt_pos_infinity
232+
%next = call float @nextafterf(float %subnormal, float %infinity) readnone
233+
ret float %next
234+
}

0 commit comments

Comments
 (0)