Auto merge of #1968 - RalfJung:rustup, r=RalfJung

rustup; implement simd_and/or

I had to disable the integer division tests since they now require simd_eq, which seems [non-trivial to implement](https://github.com/rust-lang/miri/issues/1912#issuecomment-1030164843).

Cc https://github.com/rust-lang/rust/issues/93619
This commit is contained in:
bors 2022-02-04 17:01:23 +00:00
commit a284d4f551
3 changed files with 11 additions and 5 deletions

View File

@ -1 +1 @@
009c1d02484dcc18e1596a33b3d8989a90361c89
4e8fb743ccbec27344b2dd42de7057f41d4ebfdd

View File

@ -314,7 +314,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
| "simd_div"
| "simd_rem"
| "simd_shl"
| "simd_shr" => {
| "simd_shr"
| "simd_and"
| "simd_or" => {
let &[ref left, ref right] = check_arg_count(args)?;
let (left, left_len) = this.operand_to_simd(left)?;
let (right, right_len) = this.operand_to_simd(right)?;
@ -331,6 +333,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
"simd_rem" => mir::BinOp::Rem,
"simd_shl" => mir::BinOp::Shl,
"simd_shr" => mir::BinOp::Shr,
"simd_and" => mir::BinOp::BitAnd,
"simd_or" => mir::BinOp::BitOr,
_ => unreachable!(),
};

View File

@ -18,11 +18,13 @@ fn simd_ops_i32() {
assert_eq!(a + b, i32x4::from_array([11, 12, 13, 14]));
assert_eq!(a - b, i32x4::from_array([9, 8, 7, 6]));
assert_eq!(a * b, i32x4::from_array([10, 20, 30, 40]));
assert_eq!(a / b, i32x4::from_array([10, 5, 3, 2]));
assert_eq!(a / i32x4::splat(2), i32x4::splat(5));
assert_eq!(a % b, i32x4::from_array([0, 0, 1, 2]));
//assert_eq!(a / b, i32x4::from_array([10, 5, 3, 2]));
//assert_eq!(a / i32x4::splat(2), i32x4::splat(5));
//assert_eq!(a % b, i32x4::from_array([0, 0, 1, 2]));
assert_eq!(b << i32x4::splat(2), i32x4::from_array([4, 8, 12, 16]));
assert_eq!(b >> i32x4::splat(1), i32x4::from_array([0, 1, 1, 2]));
assert_eq!(b & i32x4::splat(2), i32x4::from_array([0, 2, 2, 0]));
assert_eq!(b | i32x4::splat(2), i32x4::from_array([3, 2, 3, 6]));
}
fn main() {