Implement simd_reduce_{min,max} for floats
This commit is contained in:
parent
a8be7ea503
commit
d288c6924d
1 changed files with 12 additions and 12 deletions
|
@ -405,27 +405,27 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
||||||
};
|
};
|
||||||
|
|
||||||
simd_reduce_min, (c v) {
|
simd_reduce_min, (c v) {
|
||||||
// FIXME support floats
|
|
||||||
validate_simd_type!(fx, intrinsic, span, v.layout().ty);
|
validate_simd_type!(fx, intrinsic, span, v.layout().ty);
|
||||||
simd_reduce(fx, v, None, ret, |fx, layout, a, b| {
|
simd_reduce(fx, v, None, ret, |fx, layout, a, b| {
|
||||||
let lt = fx.bcx.ins().icmp(if layout.ty.is_signed() {
|
let lt = match layout.ty.kind() {
|
||||||
IntCC::SignedLessThan
|
ty::Int(_) => fx.bcx.ins().icmp(IntCC::SignedLessThan, a, b),
|
||||||
} else {
|
ty::Uint(_) => fx.bcx.ins().icmp(IntCC::UnsignedLessThan, a, b),
|
||||||
IntCC::UnsignedLessThan
|
ty::Float(_) => fx.bcx.ins().fcmp(FloatCC::LessThan, a, b),
|
||||||
}, a, b);
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
fx.bcx.ins().select(lt, a, b)
|
fx.bcx.ins().select(lt, a, b)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
simd_reduce_max, (c v) {
|
simd_reduce_max, (c v) {
|
||||||
// FIXME support floats
|
|
||||||
validate_simd_type!(fx, intrinsic, span, v.layout().ty);
|
validate_simd_type!(fx, intrinsic, span, v.layout().ty);
|
||||||
simd_reduce(fx, v, None, ret, |fx, layout, a, b| {
|
simd_reduce(fx, v, None, ret, |fx, layout, a, b| {
|
||||||
let gt = fx.bcx.ins().icmp(if layout.ty.is_signed() {
|
let gt = match layout.ty.kind() {
|
||||||
IntCC::SignedGreaterThan
|
ty::Int(_) => fx.bcx.ins().icmp(IntCC::SignedGreaterThan, a, b),
|
||||||
} else {
|
ty::Uint(_) => fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, a, b),
|
||||||
IntCC::UnsignedGreaterThan
|
ty::Float(_) => fx.bcx.ins().fcmp(FloatCC::GreaterThan, a, b),
|
||||||
}, a, b);
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
fx.bcx.ins().select(gt, a, b)
|
fx.bcx.ins().select(gt, a, b)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue