Skip to content

Commit 6d2221d

Browse files
committed
Fix simd_round implementation
1 parent 90e4493 commit 6d2221d

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/intrinsics/simd.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,23 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
289289

290290
simd_round, (c a) {
291291
validate_simd_type!(fx, intrinsic, span, a.layout().ty);
292-
simd_for_each_lane(fx, a, ret, |fx, _lane_layout, ret_lane_layout, lane| {
293-
let ret_lane = fx.bcx.ins().nearest(lane);
294-
CValue::by_val(ret_lane, ret_lane_layout)
292+
simd_for_each_lane(fx, a, ret, |fx, lane_layout, ret_lane_layout, lane| {
293+
let res_lane = match lane_layout.ty.kind() {
294+
ty::Float(FloatTy::F32) => fx.lib_call(
295+
"roundf",
296+
vec![AbiParam::new(types::F32)],
297+
vec![AbiParam::new(types::F32)],
298+
&[lane],
299+
)[0],
300+
ty::Float(FloatTy::F64) => fx.lib_call(
301+
"round",
302+
vec![AbiParam::new(types::F64)],
303+
vec![AbiParam::new(types::F64)],
304+
&[lane],
305+
)[0],
306+
_ => unreachable!("{:?}", lane_layout.ty),
307+
};
308+
CValue::by_val(res_lane, ret_lane_layout)
295309
});
296310
};
297311
simd_ceil, (c a) {
@@ -409,5 +423,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
409423

410424
// simd_saturating_*
411425
// simd_bitmask
426+
// simd_scatter
427+
// simd_gather
412428
}
413429
}

0 commit comments

Comments
 (0)