Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/intrinsics/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
"powf16" => pow_intrinsic::<HalfS>(this, args, dest)?,
"powf32" => pow_intrinsic::<SingleS>(this, args, dest)?,
"powf64" => pow_intrinsic::<DoubleS>(this, args, dest)?,
"powf128" => todo!("f128"), // FIXME(f128)

"powif16" => powi_intrinsic::<HalfS>(this, args, dest)?,
"powif32" => powi_intrinsic::<SingleS>(this, args, dest)?,
"powif64" => powi_intrinsic::<DoubleS>(this, args, dest)?,
"powif128" => todo!("f128"), // FIXME(f128)

_ => return interp_ok(EmulateItemResult::NotSupported),
}
Expand Down
6 changes: 3 additions & 3 deletions src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_apfloat::ieee::{DoubleS, HalfS, IeeeFloat, SingleS};
use rustc_apfloat::ieee::{DoubleS, HalfS, IeeeFloat, QuadS, SingleS};
use rustc_middle::ty;
use rustc_middle::ty::FloatTy;

Expand Down Expand Up @@ -36,7 +36,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
FloatTy::F16 => math::sqrt_op::<IeeeFloat<HalfS>>(this, &op, &dest)?,
FloatTy::F32 => math::sqrt_op::<IeeeFloat<SingleS>>(this, &op, &dest)?,
FloatTy::F64 => math::sqrt_op::<IeeeFloat<DoubleS>>(this, &op, &dest)?,
FloatTy::F128 => unimplemented!("f128"),
FloatTy::F128 => math::sqrt_op::<IeeeFloat<QuadS>>(this, &op, &dest)?,
};
}
}
Expand Down Expand Up @@ -72,7 +72,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
FloatTy::F16 => host_unary_float_op::<HalfS>(this, &op, host_op, &dest)?,
FloatTy::F32 => host_unary_float_op::<SingleS>(this, &op, host_op, &dest)?,
FloatTy::F64 => host_unary_float_op::<DoubleS>(this, &op, host_op, &dest)?,
FloatTy::F128 => unimplemented!("f128"),
FloatTy::F128 => unimplemented!("f128"), // FIXME(f128)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it, do you also want to add FIXMEs for powf128 and powif128?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed

}
}
}
Expand Down
12 changes: 12 additions & 0 deletions tests/pass/intrinsics/portable-simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::ptr;
use std::simd::StdFloat;
use std::simd::prelude::*;

// The `portable_simd` crate currently does not support f16 or f128 vectors, so we define our own.
Comment thread
RalfJung marked this conversation as resolved.
#[repr(simd, packed)]
#[derive(Copy)]
struct PackedSimd<T, const N: usize>([T; N]);
Expand Down Expand Up @@ -113,6 +114,9 @@ fn simd_ops_f16() {
f16x4::splat(f16::NEG_INFINITY)
);

assert_eq!(simd_fsqrt(simd_mul(a, a)), a);
assert_eq!(simd_fsqrt(simd_mul(b, b)), simd_fabs(b));

assert_eq!(simd_eq(a, simd_mul(f16x4::splat(5.0), b)), i32x4::from_array([0, !0, 0, 0]));
assert_eq!(simd_ne(a, simd_mul(f16x4::splat(5.0), b)), i32x4::from_array([!0, 0, !0, !0]));
assert_eq!(simd_le(a, simd_mul(f16x4::splat(5.0), b)), i32x4::from_array([0, !0, !0, 0]));
Expand Down Expand Up @@ -324,6 +328,9 @@ fn simd_ops_f128() {
f128x4::splat(f128::NEG_INFINITY)
);

assert_eq!(simd_fsqrt(simd_mul(a, a)), a);
assert_eq!(simd_fsqrt(simd_mul(b, b)), simd_fabs(b));

assert_eq!(simd_eq(a, simd_mul(f128x4::splat(5.0), b)), i32x4::from_array([0, !0, 0, 0]));
assert_eq!(simd_ne(a, simd_mul(f128x4::splat(5.0), b)), i32x4::from_array([!0, 0, !0, !0]));
assert_eq!(simd_le(a, simd_mul(f128x4::splat(5.0), b)), i32x4::from_array([0, !0, !0, 0]));
Expand Down Expand Up @@ -970,6 +977,11 @@ fn simd_float_intrinsics() {
simd_flog2(a);
simd_flog10(a);
}

unsafe {
let a = f128x2::splat(10.0);
simd_fsqrt(a);
}
}

fn simd_masked_loadstore() {
Expand Down
Loading