diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-12-15 11:09:45 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-12-15 11:09:45 +0000 |
| commit | f626185a5b792c171297d1e9a6b8d166348a5e53 (patch) | |
| tree | 24a371b73e2b705766a0b7a7a3f09f525f529ab7 | |
| parent | 808cba2251aba868a97b67ad7d5d7cecc9024f93 (diff) | |
| download | rust-f626185a5b792c171297d1e9a6b8d166348a5e53.tar.gz rust-f626185a5b792c171297d1e9a6b8d166348a5e53.zip | |
Update portable-simd to 582239ac3b32007613df04d7ffa78dc30f4c5645
| -rw-r--r-- | build_system/tests.rs | 2 | ||||
| -rw-r--r-- | patches/0001-portable-simd-Disable-unsupported-tests.patch | 4 | ||||
| -rw-r--r-- | src/intrinsics/simd.rs | 32 |
3 files changed, 34 insertions, 4 deletions
diff --git a/build_system/tests.rs b/build_system/tests.rs index 7a12c1a54d4..2131b88c232 100644 --- a/build_system/tests.rs +++ b/build_system/tests.rs @@ -244,7 +244,7 @@ static REGEX: CargoProject = CargoProject::new(®EX_REPO.source_dir(), "regex" pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github( "rust-lang", "portable-simd", - "d5cd4a8112d958bd3a252327e0d069a6363249bd", + "582239ac3b32007613df04d7ffa78dc30f4c5645", "portable-simd", ); diff --git a/patches/0001-portable-simd-Disable-unsupported-tests.patch b/patches/0001-portable-simd-Disable-unsupported-tests.patch index 89e2b61c1fc..bdf727666be 100644 --- a/patches/0001-portable-simd-Disable-unsupported-tests.patch +++ b/patches/0001-portable-simd-Disable-unsupported-tests.patch @@ -24,8 +24,8 @@ index e8e8f68..7173c24 100644 /// If an index is out-of-bounds, the lane is instead selected from the `or` vector. /// @@ -473,6 +474,7 @@ where - // Cleared ☢️ *mut T Zone - } + // Safety: The caller is responsible for upholding all invariants + unsafe { intrinsics::simd_scatter(self, dest, enable.to_int()) } } + */ } diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 14f5e918739..a6f5f70dc4c 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -770,7 +770,37 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }); } - // simd_arith_offset + sym::simd_expose_addr | sym::simd_from_exposed_addr | sym::simd_cast_ptr => { + intrinsic_args!(fx, args => (arg); intrinsic); + ret.write_cvalue_transmute(fx, arg); + } + + sym::simd_arith_offset => { + intrinsic_args!(fx, args => (ptr, offset); intrinsic); + + let (lane_count, ptr_lane_ty) = ptr.layout().ty.simd_size_and_type(fx.tcx); + let pointee_ty = ptr_lane_ty.builtin_deref(true).unwrap().ty; + let pointee_size = fx.layout_of(pointee_ty).size.bytes(); + let (ret_lane_count, ret_lane_ty) = ret.layout().ty.simd_size_and_type(fx.tcx); + let ret_lane_layout = fx.layout_of(ret_lane_ty); + assert_eq!(lane_count, ret_lane_count); + + for lane_idx in 0..lane_count { + let ptr_lane = ptr.value_lane(fx, lane_idx).load_scalar(fx); + let offset_lane = offset.value_lane(fx, lane_idx).load_scalar(fx); + + let ptr_diff = if pointee_size != 1 { + fx.bcx.ins().imul_imm(offset_lane, pointee_size as i64) + } else { + offset_lane + }; + let res_lane = fx.bcx.ins().iadd(ptr_lane, ptr_diff); + let res_lane = CValue::by_val(res_lane, ret_lane_layout); + + ret.place_lane(fx, lane_idx).write_cvalue(fx, res_lane); + } + } + // simd_scatter // simd_gather _ => { |
