Skip to content

Commit 0065b07

Browse files
committed
Precommit tests
1 parent cc3a505 commit 0065b07

File tree

5 files changed

+812
-0
lines changed

5 files changed

+812
-0
lines changed
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
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 noundef, double noundef) #0
5+
declare float @nextafterf(float noundef, float noundef) #0
6+
7+
attributes #0 = { willreturn memory(errnomem: write) }
8+
9+
; ==================
10+
; nextafter tests
11+
; ==================
12+
13+
define double @nextafter_can_constant_fold_up_direction() {
14+
; CHECK-LABEL: define double @nextafter_can_constant_fold_up_direction() {
15+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double noundef 1.000000e+00, double noundef 2.000000e+00)
16+
; CHECK-NEXT: ret double [[NEXT]]
17+
;
18+
%next = call double @nextafter(double noundef 1.0, double noundef 2.0)
19+
ret double %next
20+
}
21+
define double @nextafter_can_constant_fold_down_direction() {
22+
; CHECK-LABEL: define double @nextafter_can_constant_fold_down_direction() {
23+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double noundef 1.000000e+00, double noundef 0.000000e+00)
24+
; CHECK-NEXT: ret double [[NEXT]]
25+
;
26+
%next = call double @nextafter(double noundef 1.0, double noundef 0.0)
27+
ret double %next
28+
}
29+
define double @nextafter_can_constant_fold_equal_args() {
30+
; CHECK-LABEL: define double @nextafter_can_constant_fold_equal_args() {
31+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double noundef 1.000000e+00, double noundef 1.000000e+00)
32+
; CHECK-NEXT: ret double [[NEXT]]
33+
;
34+
%next = call double @nextafter(double noundef 1.0, double noundef 1.0)
35+
ret double %next
36+
}
37+
define double @nextafter_can_constant_fold_with_nan_arg() {
38+
; CHECK-LABEL: define double @nextafter_can_constant_fold_with_nan_arg() {
39+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 1.000000e+00, double 0x7FF8000000000000)
40+
; CHECK-NEXT: ret double [[NEXT]]
41+
;
42+
%arg = load double, double* @dbl_nan
43+
%next = call double @nextafter(double 1.0, double %arg)
44+
ret double %next
45+
}
46+
define double @nextafter_not_marked_dead_on_pos_overflow () {
47+
; CHECK-LABEL: define double @nextafter_not_marked_dead_on_pos_overflow() {
48+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 0x7FEFFFFFFFFFFFFF, double 0x7FF0000000000000)
49+
; CHECK-NEXT: ret double [[NEXT]]
50+
;
51+
%arg1 = load double, double* @dbl_pos_max
52+
%arg2 = load double, double* @dbl_pos_infinity
53+
%next = call double @nextafter(double %arg1, double %arg2)
54+
ret double %next
55+
}
56+
define double @nextafter_not_marked_dead_on_neg_overflow() {
57+
; CHECK-LABEL: define double @nextafter_not_marked_dead_on_neg_overflow() {
58+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 0xFFEFFFFFFFFFFFFF, double 0xFFF0000000000000)
59+
; CHECK-NEXT: ret double [[NEXT]]
60+
;
61+
%arg1 = load double, double* @dbl_neg_max
62+
%arg2 = load double, double* @dbl_neg_infinity
63+
%next = call double @nextafter(double %arg1, double %arg2)
64+
ret double %next
65+
}
66+
define double @nextafter_not_marked_dead_on_zero_from_above() {
67+
; CHECK-LABEL: define double @nextafter_not_marked_dead_on_zero_from_above() {
68+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 4.940660e-324, double 0.000000e+00)
69+
; CHECK-NEXT: ret double [[NEXT]]
70+
;
71+
%arg = load double, double* @dbl_pos_min_subnormal
72+
%next = call double @nextafter(double %arg, double 0.0)
73+
ret double %next
74+
}
75+
define double @nextafter_not_marked_dead_on_zero_from_below() {
76+
; CHECK-LABEL: define double @nextafter_not_marked_dead_on_zero_from_below() {
77+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double -4.940660e-324, double 0.000000e+00)
78+
; CHECK-NEXT: ret double [[NEXT]]
79+
;
80+
%arg = load double, double* @dbl_neg_min_subnormal
81+
%next = call double @nextafter(double %arg, double 0.0)
82+
ret double %next
83+
}
84+
define double @nextafter_not_marked_dead_on_subnormal() {
85+
; CHECK-LABEL: define double @nextafter_not_marked_dead_on_subnormal() {
86+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nextafter(double 4.940660e-324, double 0x7FF0000000000000)
87+
; CHECK-NEXT: ret double [[NEXT]]
88+
;
89+
%subnormal = load double, double* @dbl_pos_min_subnormal
90+
%infinity = load double, double* @dbl_pos_infinity
91+
%next = call double @nextafter(double %subnormal, double %infinity)
92+
ret double %next
93+
}
94+
95+
; ==================
96+
; nextafterf tests
97+
; ==================
98+
99+
define float @nextafterf_can_constant_fold_up_direction() {
100+
; CHECK-LABEL: define float @nextafterf_can_constant_fold_up_direction() {
101+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float noundef 1.000000e+00, float noundef 2.000000e+00)
102+
; CHECK-NEXT: ret float [[NEXT]]
103+
;
104+
%next = call float @nextafterf(float noundef 1.0, float noundef 2.0)
105+
ret float %next
106+
}
107+
define float @nextafterf_can_constant_fold_down_direction() {
108+
; CHECK-LABEL: define float @nextafterf_can_constant_fold_down_direction() {
109+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float noundef 1.000000e+00, float noundef 0.000000e+00)
110+
; CHECK-NEXT: ret float [[NEXT]]
111+
;
112+
%next = call float @nextafterf(float noundef 1.0, float noundef 0.0)
113+
ret float %next
114+
}
115+
define float @nextafterf_can_constant_fold_equal_args() {
116+
; CHECK-LABEL: define float @nextafterf_can_constant_fold_equal_args() {
117+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float noundef 1.000000e+00, float noundef 1.000000e+00)
118+
; CHECK-NEXT: ret float [[NEXT]]
119+
;
120+
%next = call float @nextafterf(float noundef 1.0, float noundef 1.0)
121+
ret float %next
122+
}
123+
define float @nextafterf_can_constant_fold_with_nan_arg() {
124+
; CHECK-LABEL: define float @nextafterf_can_constant_fold_with_nan_arg() {
125+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 1.000000e+00, float 0x7FF8000000000000)
126+
; CHECK-NEXT: ret float [[NEXT]]
127+
;
128+
%arg = load float, float* @flt_nan
129+
%next = call float @nextafterf(float 1.0, float %arg)
130+
ret float %next
131+
}
132+
define float @nextafterf_not_marked_dead_on_pos_overflow() {
133+
; CHECK-LABEL: define float @nextafterf_not_marked_dead_on_pos_overflow() {
134+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0x47EFFFFFE0000000, float 0x7FF0000000000000)
135+
; CHECK-NEXT: ret float [[NEXT]]
136+
;
137+
%arg1 = load float, float* @flt_pos_max
138+
%arg2 = load float, float* @flt_pos_infinity
139+
%next = call float @nextafterf(float %arg1, float %arg2)
140+
ret float %next
141+
}
142+
define float @nextafterf_not_marked_dead_on_neg_overflow() {
143+
; CHECK-LABEL: define float @nextafterf_not_marked_dead_on_neg_overflow() {
144+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0xC7EFFFFFE0000000, float 0xFFF0000000000000)
145+
; CHECK-NEXT: ret float [[NEXT]]
146+
;
147+
%arg1 = load float, float* @flt_neg_max
148+
%arg2 = load float, float* @flt_neg_infinity
149+
%next = call float @nextafterf(float %arg1, float %arg2)
150+
ret float %next
151+
}
152+
define float @nextafterf_not_marked_dead_on_zero_from_above() {
153+
; CHECK-LABEL: define float @nextafterf_not_marked_dead_on_zero_from_above() {
154+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0x36A0000000000000, float 0.000000e+00)
155+
; CHECK-NEXT: ret float [[NEXT]]
156+
;
157+
%arg = load float, float* @flt_pos_min_subnormal
158+
%next = call float @nextafterf(float %arg, float 0.0)
159+
ret float %next
160+
}
161+
define float @nextafterf_not_marked_dead_on_zero_from_below() {
162+
; CHECK-LABEL: define float @nextafterf_not_marked_dead_on_zero_from_below() {
163+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0xB6A0000000000000, float 0.000000e+00)
164+
; CHECK-NEXT: ret float [[NEXT]]
165+
;
166+
%arg = load float, float* @flt_neg_min_subnormal
167+
%next = call float @nextafterf(float %arg, float 0.0)
168+
ret float %next
169+
}
170+
define float @nextafterf_not_marked_dead_on_subnormal() {
171+
; CHECK-LABEL: define float @nextafterf_not_marked_dead_on_subnormal() {
172+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nextafterf(float 0x36A0000000000000, float 0x7FF0000000000000)
173+
; CHECK-NEXT: ret float [[NEXT]]
174+
;
175+
%subnormal = load float, float* @flt_pos_min_subnormal
176+
%infinity = load float, float* @flt_pos_infinity
177+
%next = call float @nextafterf(float %subnormal, float %infinity)
178+
ret float %next
179+
}
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
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 @nexttoward(double noundef, fp128 noundef) #0
5+
declare float @nexttowardf(float noundef, fp128 noundef) #0
6+
7+
attributes #0 = { willreturn memory(errnomem: write) }
8+
9+
; ==================
10+
; nexttoward tests
11+
; ==================
12+
13+
define double @nexttoward_can_constant_fold_up_direction() {
14+
; CHECK-LABEL: define double @nexttoward_can_constant_fold_up_direction() {
15+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double noundef 1.000000e+00, fp128 0xL00000000000000004000000000000000)
16+
; CHECK-NEXT: ret double [[NEXT]]
17+
;
18+
%arg = fpext double 2.0 to fp128
19+
%next = call double @nexttoward(double noundef 1.0, fp128 %arg)
20+
ret double %next
21+
}
22+
define double @nexttoward_can_constant_fold_down_direction() {
23+
; CHECK-LABEL: define double @nexttoward_can_constant_fold_down_direction() {
24+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double noundef 1.000000e+00, fp128 0xL00000000000000000000000000000000)
25+
; CHECK-NEXT: ret double [[NEXT]]
26+
;
27+
%arg = fpext double 0.0 to fp128
28+
%next = call double @nexttoward(double noundef 1.0, fp128 %arg)
29+
ret double %next
30+
}
31+
define double @nexttoward_can_constant_fold_equal_args() {
32+
; CHECK-LABEL: define double @nexttoward_can_constant_fold_equal_args() {
33+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double 1.000000e+00, fp128 0xL00000000000000003FFF000000000000)
34+
; CHECK-NEXT: ret double [[NEXT]]
35+
;
36+
%arg = fpext double 1.0 to fp128
37+
%next = call double @nexttoward(double 1.0, fp128 %arg)
38+
ret double %next
39+
}
40+
define double @nexttoward_can_constant_fold_with_nan_arg() {
41+
; CHECK-LABEL: define double @nexttoward_can_constant_fold_with_nan_arg() {
42+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double 1.000000e+00, fp128 0xL00000000000000007FFF800000000000)
43+
; CHECK-NEXT: ret double [[NEXT]]
44+
;
45+
%nan = load double, double* @dbl_nan
46+
%arg = fpext double %nan to fp128
47+
%next = call double @nexttoward(double 1.0, fp128 %arg)
48+
ret double %next
49+
}
50+
define double @nexttoward_not_marked_dead_on_pos_overflow() {
51+
; CHECK-LABEL: define double @nexttoward_not_marked_dead_on_pos_overflow() {
52+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double 0x7FEFFFFFFFFFFFFF, fp128 0xL00000000000000007FFF000000000000)
53+
; CHECK-NEXT: ret double [[NEXT]]
54+
;
55+
%pos_max = load double, double* @dbl_pos_max
56+
%pos_inf = load double, double* @dbl_pos_infinity
57+
%ext_pos_inf = fpext double %pos_inf to fp128
58+
%next = call double @nexttoward(double %pos_max, fp128 %ext_pos_inf)
59+
ret double %next
60+
}
61+
define double @nexttoward_not_marked_dead_on_neg_overflow() {
62+
; CHECK-LABEL: define double @nexttoward_not_marked_dead_on_neg_overflow() {
63+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double 0xFFEFFFFFFFFFFFFF, fp128 0xL0000000000000000FFFF000000000000)
64+
; CHECK-NEXT: ret double [[NEXT]]
65+
;
66+
%neg_max = load double, double* @dbl_neg_max
67+
%neg_inf = load double, double* @dbl_neg_infinity
68+
%ext_neg_inf = fpext double %neg_inf to fp128
69+
%next = call double @nexttoward(double %neg_max, fp128 %ext_neg_inf)
70+
ret double %next
71+
}
72+
define double @nexttoward_not_marked_dead_on_zero_from_above() {
73+
; CHECK-LABEL: define double @nexttoward_not_marked_dead_on_zero_from_above() {
74+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double 4.940660e-324, fp128 0xL00000000000000000000000000000000)
75+
; CHECK-NEXT: ret double [[NEXT]]
76+
;
77+
%subnormal = load double, double* @dbl_pos_min_subnormal
78+
%zero = fpext double 0.0 to fp128
79+
%next = call double @nexttoward(double %subnormal, fp128 %zero)
80+
ret double %next
81+
}
82+
define double @nexttoward_not_marked_dead_on_zero_from_below() {
83+
; CHECK-LABEL: define double @nexttoward_not_marked_dead_on_zero_from_below() {
84+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double -4.940660e-324, fp128 0xL00000000000000000000000000000000)
85+
; CHECK-NEXT: ret double [[NEXT]]
86+
;
87+
%subnormal = load double, double* @dbl_neg_min_subnormal
88+
%zero = fpext double 0.0 to fp128
89+
%next = call double @nexttoward(double %subnormal, fp128 %zero)
90+
ret double %next
91+
}
92+
define double @nexttoward_not_marked_dead_on_subnormal() {
93+
; CHECK-LABEL: define double @nexttoward_not_marked_dead_on_subnormal() {
94+
; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double 4.940660e-324, fp128 0xL00000000000000003FFF000000000000)
95+
; CHECK-NEXT: ret double [[NEXT]]
96+
;
97+
%subnormal = load double, double* @dbl_pos_min_subnormal
98+
%target = fpext double 1.0 to fp128
99+
%next = call double @nexttoward(double %subnormal, fp128 %target)
100+
ret double %next
101+
}
102+
103+
; ==================
104+
; nexttowardf tests
105+
; ==================
106+
107+
define float @nexttowardf_can_constant_fold_up_direction() {
108+
; CHECK-LABEL: define float @nexttowardf_can_constant_fold_up_direction() {
109+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float noundef 1.000000e+00, fp128 0xL00000000000000004000000000000000)
110+
; CHECK-NEXT: ret float [[NEXT]]
111+
;
112+
%arg = fpext float 2.0 to fp128
113+
%next = call float @nexttowardf(float noundef 1.0, fp128 %arg)
114+
ret float %next
115+
}
116+
define float @nexttowardf_can_constant_fold_down_direction() {
117+
; CHECK-LABEL: define float @nexttowardf_can_constant_fold_down_direction() {
118+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float noundef 1.000000e+00, fp128 0xL00000000000000000000000000000000)
119+
; CHECK-NEXT: ret float [[NEXT]]
120+
;
121+
%arg = fpext float 0.0 to fp128
122+
%next = call float @nexttowardf(float noundef 1.0, fp128 %arg)
123+
ret float %next
124+
}
125+
define float @nexttowardf_can_constant_fold_equal_args() {
126+
; CHECK-LABEL: define float @nexttowardf_can_constant_fold_equal_args() {
127+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttoward(float 1.000000e+00, fp128 0xL00000000000000003FFF000000000000)
128+
; CHECK-NEXT: ret float [[NEXT]]
129+
;
130+
%arg = fpext float 1.0 to fp128
131+
%next = call float @nexttoward(float 1.0, fp128 %arg)
132+
ret float %next
133+
}
134+
define float @nexttowardf_can_constant_fold_with_nan_arg() {
135+
; CHECK-LABEL: define float @nexttowardf_can_constant_fold_with_nan_arg() {
136+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float 1.000000e+00, fp128 0xL00000000000000007FFF800000000000)
137+
; CHECK-NEXT: ret float [[NEXT]]
138+
;
139+
%nan = load float, float* @flt_nan
140+
%ext_nan = fpext float %nan to fp128
141+
%next = call float @nexttowardf(float 1.0, fp128 %ext_nan)
142+
ret float %next
143+
}
144+
define float @nexttowardf_not_marked_dead_on_pos_overflow () {
145+
; CHECK-LABEL: define float @nexttowardf_not_marked_dead_on_pos_overflow() {
146+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float 0x47EFFFFFE0000000, fp128 0xL00000000000000007FFF000000000000)
147+
; CHECK-NEXT: ret float [[NEXT]]
148+
;
149+
%pos_max = load float, float* @flt_pos_max
150+
%pos_inf = load float, float* @flt_pos_infinity
151+
%ext_pos_inf = fpext float %pos_inf to fp128
152+
%next = call float @nexttowardf(float %pos_max, fp128 %ext_pos_inf)
153+
ret float %next
154+
}
155+
define float @nexttowardf_not_marked_dead_on_neg_overflow() {
156+
; CHECK-LABEL: define float @nexttowardf_not_marked_dead_on_neg_overflow() {
157+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float 0xC7EFFFFFE0000000, fp128 0xL0000000000000000FFFF000000000000)
158+
; CHECK-NEXT: ret float [[NEXT]]
159+
;
160+
%neg_max = load float, float* @flt_neg_max
161+
%neg_inf = load float, float* @flt_neg_infinity
162+
%ext_neg_inf = fpext float %neg_inf to fp128
163+
%next = call float @nexttowardf(float %neg_max, fp128 %ext_neg_inf)
164+
ret float %next
165+
}
166+
define float @nexttowardf_not_marked_dead_on_zero_from_above() {
167+
; CHECK-LABEL: define float @nexttowardf_not_marked_dead_on_zero_from_above() {
168+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float 0x36A0000000000000, fp128 0xL00000000000000000000000000000000)
169+
; CHECK-NEXT: ret float [[NEXT]]
170+
;
171+
%min_subnormal = load float, float* @flt_pos_min_subnormal
172+
%zero = fpext float 0.0 to fp128
173+
%next = call float @nexttowardf(float %min_subnormal, fp128 %zero)
174+
ret float %next
175+
}
176+
define float @nexttowardf_not_marked_dead_on_zero_from_below() {
177+
; CHECK-LABEL: define float @nexttowardf_not_marked_dead_on_zero_from_below() {
178+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float 0xB6A0000000000000, fp128 0xL00000000000000000000000000000000)
179+
; CHECK-NEXT: ret float [[NEXT]]
180+
;
181+
%min_subnormal = load float, float* @flt_neg_min_subnormal
182+
%zero = fpext float 0.0 to fp128
183+
%next = call float @nexttowardf(float %min_subnormal, fp128 %zero)
184+
ret float %next
185+
}
186+
define float @nexttowardf_not_marked_dead_on_subnormal() {
187+
; CHECK-LABEL: define float @nexttowardf_not_marked_dead_on_subnormal() {
188+
; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float 0x36A0000000000000, fp128 0xL00000000000000003FFF000000000000)
189+
; CHECK-NEXT: ret float [[NEXT]]
190+
;
191+
%subnormal = load float, float* @flt_pos_min_subnormal
192+
%target = fpext float 1.0 to fp128
193+
%next = call float @nexttowardf(float %subnormal, fp128 %target)
194+
ret float %next
195+
}

0 commit comments

Comments
 (0)