Skip to content

Commit d288c69

Browse files
committed
Implement simd_reduce_{min,max} for floats
1 parent a8be7ea commit d288c69

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/intrinsics/simd.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -405,27 +405,27 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
405405
};
406406

407407
simd_reduce_min, (c v) {
408-
// FIXME support floats
409408
validate_simd_type!(fx, intrinsic, span, v.layout().ty);
410409
simd_reduce(fx, v, None, ret, |fx, layout, a, b| {
411-
let lt = fx.bcx.ins().icmp(if layout.ty.is_signed() {
412-
IntCC::SignedLessThan
413-
} else {
414-
IntCC::UnsignedLessThan
415-
}, a, b);
410+
let lt = match layout.ty.kind() {
411+
ty::Int(_) => fx.bcx.ins().icmp(IntCC::SignedLessThan, a, b),
412+
ty::Uint(_) => fx.bcx.ins().icmp(IntCC::UnsignedLessThan, a, b),
413+
ty::Float(_) => fx.bcx.ins().fcmp(FloatCC::LessThan, a, b),
414+
_ => unreachable!(),
415+
};
416416
fx.bcx.ins().select(lt, a, b)
417417
});
418418
};
419419

420420
simd_reduce_max, (c v) {
421-
// FIXME support floats
422421
validate_simd_type!(fx, intrinsic, span, v.layout().ty);
423422
simd_reduce(fx, v, None, ret, |fx, layout, a, b| {
424-
let gt = fx.bcx.ins().icmp(if layout.ty.is_signed() {
425-
IntCC::SignedGreaterThan
426-
} else {
427-
IntCC::UnsignedGreaterThan
428-
}, a, b);
423+
let gt = match layout.ty.kind() {
424+
ty::Int(_) => fx.bcx.ins().icmp(IntCC::SignedGreaterThan, a, b),
425+
ty::Uint(_) => fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, a, b),
426+
ty::Float(_) => fx.bcx.ins().fcmp(FloatCC::GreaterThan, a, b),
427+
_ => unreachable!(),
428+
};
429429
fx.bcx.ins().select(gt, a, b)
430430
});
431431
};

0 commit comments

Comments
 (0)