@@ -145,17 +145,30 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
145145 "fabsf32" => {
146146 let [ f] = check_arg_count ( args) ?;
147147 let f = this. read_scalar ( f) ?. to_f32 ( ) ?;
148- // Can be implemented in soft-floats.
149148 // This is a "bitwise" operation, so there's no NaN non-determinism.
150149 this. write_scalar ( Scalar :: from_f32 ( f. abs ( ) ) , dest) ?;
151150 }
152151 "fabsf64" => {
153152 let [ f] = check_arg_count ( args) ?;
154153 let f = this. read_scalar ( f) ?. to_f64 ( ) ?;
155- // Can be implemented in soft-floats.
156154 // This is a "bitwise" operation, so there's no NaN non-determinism.
157155 this. write_scalar ( Scalar :: from_f64 ( f. abs ( ) ) , dest) ?;
158156 }
157+ "floorf32" | "ceilf32" | "truncf32" | "roundf32" | "rintf32" => {
158+ let [ f] = check_arg_count ( args) ?;
159+ let f = this. read_scalar ( f) ?. to_f32 ( ) ?;
160+ let mode = match intrinsic_name {
161+ "floorf32" => Round :: TowardNegative ,
162+ "ceilf32" => Round :: TowardPositive ,
163+ "truncf32" => Round :: TowardZero ,
164+ "roundf32" => Round :: NearestTiesToAway ,
165+ "rintf32" => Round :: NearestTiesToEven ,
166+ _ => bug ! ( ) ,
167+ } ;
168+ let res = f. round_to_integral ( mode) . value ;
169+ let res = this. adjust_nan ( res, & [ f] ) ;
170+ this. write_scalar ( res, dest) ?;
171+ }
159172 #[ rustfmt:: skip]
160173 | "sinf32"
161174 | "cosf32"
@@ -165,11 +178,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
165178 | "logf32"
166179 | "log10f32"
167180 | "log2f32"
168- | "floorf32"
169- | "ceilf32"
170- | "truncf32"
171- | "roundf32"
172- | "rintf32"
173181 => {
174182 let [ f] = check_arg_count ( args) ?;
175183 let f = this. read_scalar ( f) ?. to_f32 ( ) ?;
@@ -184,18 +192,28 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
184192 "logf32" => f_host. ln ( ) ,
185193 "log10f32" => f_host. log10 ( ) ,
186194 "log2f32" => f_host. log2 ( ) ,
187- "floorf32" => f_host. floor ( ) ,
188- "ceilf32" => f_host. ceil ( ) ,
189- "truncf32" => f_host. trunc ( ) ,
190- "roundf32" => f_host. round ( ) ,
191- "rintf32" => f_host. round_ties_even ( ) ,
192195 _ => bug ! ( ) ,
193196 } ;
194197 let res = res. to_soft ( ) ;
195198 let res = this. adjust_nan ( res, & [ f] ) ;
196199 this. write_scalar ( res, dest) ?;
197200 }
198201
202+ "floorf64" | "ceilf64" | "truncf64" | "roundf64" | "rintf64" => {
203+ let [ f] = check_arg_count ( args) ?;
204+ let f = this. read_scalar ( f) ?. to_f64 ( ) ?;
205+ let mode = match intrinsic_name {
206+ "floorf64" => Round :: TowardNegative ,
207+ "ceilf64" => Round :: TowardPositive ,
208+ "truncf64" => Round :: TowardZero ,
209+ "roundf64" => Round :: NearestTiesToAway ,
210+ "rintf64" => Round :: NearestTiesToEven ,
211+ _ => bug ! ( ) ,
212+ } ;
213+ let res = f. round_to_integral ( mode) . value ;
214+ let res = this. adjust_nan ( res, & [ f] ) ;
215+ this. write_scalar ( res, dest) ?;
216+ }
199217 #[ rustfmt:: skip]
200218 | "sinf64"
201219 | "cosf64"
@@ -205,11 +223,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
205223 | "logf64"
206224 | "log10f64"
207225 | "log2f64"
208- | "floorf64"
209- | "ceilf64"
210- | "truncf64"
211- | "roundf64"
212- | "rintf64"
213226 => {
214227 let [ f] = check_arg_count ( args) ?;
215228 let f = this. read_scalar ( f) ?. to_f64 ( ) ?;
@@ -224,11 +237,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
224237 "logf64" => f_host. ln ( ) ,
225238 "log10f64" => f_host. log10 ( ) ,
226239 "log2f64" => f_host. log2 ( ) ,
227- "floorf64" => f_host. floor ( ) ,
228- "ceilf64" => f_host. ceil ( ) ,
229- "truncf64" => f_host. trunc ( ) ,
230- "roundf64" => f_host. round ( ) ,
231- "rintf64" => f_host. round_ties_even ( ) ,
232240 _ => bug ! ( ) ,
233241 } ;
234242 let res = res. to_soft ( ) ;
0 commit comments