diff --git a/cranelift/filetests/filetests/runtests/simd-ineg.clif b/cranelift/filetests/filetests/runtests/simd-ineg.clif index a232a39fda..4f46bd048f 100644 --- a/cranelift/filetests/filetests/runtests/simd-ineg.clif +++ b/cranelift/filetests/filetests/runtests/simd-ineg.clif @@ -1,3 +1,4 @@ +test interpret test run target aarch64 target s390x diff --git a/cranelift/interpreter/src/value.rs b/cranelift/interpreter/src/value.rs index abde5302d5..49a6bfe7a2 100644 --- a/cranelift/interpreter/src/value.rs +++ b/cranelift/interpreter/src/value.rs @@ -263,7 +263,14 @@ macro_rules! bitop { impl DataValueExt for DataValue { fn int(n: i128, ty: Type) -> ValueResult { - if ty.is_int() && !ty.is_vector() { + if ty.is_vector() { + // match ensures graceful failure since read_from_slice_ne() + // panics on anything other than 8 and 16 bytes + match ty.bytes() { + 8 | 16 => Ok(DataValue::read_from_slice_ne(&n.to_ne_bytes(), ty)), + _ => Err(ValueError::InvalidType(ValueTypeClass::Vector, ty)), + } + } else if ty.is_int() { DataValue::from_integer(n, ty).map_err(|_| ValueError::InvalidValue(ty)) } else { Err(ValueError::InvalidType(ValueTypeClass::Integer, ty))