Skip to content

Commit 3056bf7

Browse files
committed
Auto merge of #148425 - matthiaskrgr:rollup-pwibmxt, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - rust-lang/rust#146260 (add SliceIndex wrapper types Last and Clamp<Idx>) - rust-lang/rust#148394 (Make explicit that `TypeId`'s layout and size are unstable) - rust-lang/rust#148402 (stdarch subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3affe26 + 7bb267f commit 3056bf7

File tree

5 files changed

+23
-77
lines changed

5 files changed

+23
-77
lines changed

src/shims/x86/avx.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -217,50 +217,6 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
217217
)?;
218218
}
219219
}
220-
// Used to implement the _mm256_permute2f128_ps, _mm256_permute2f128_pd and
221-
// _mm256_permute2f128_si256 functions. Regardless of the suffix in the name
222-
// thay all can be considered to operate on vectors of 128-bit elements.
223-
// For each 128-bit element of `dest`, copies one from `left`, `right` or
224-
// zero, according to `imm`.
225-
"vperm2f128.ps.256" | "vperm2f128.pd.256" | "vperm2f128.si.256" => {
226-
let [left, right, imm] =
227-
this.check_shim_sig_lenient(abi, CanonAbi::C, link_name, args)?;
228-
229-
assert_eq!(dest.layout, left.layout);
230-
assert_eq!(dest.layout, right.layout);
231-
assert_eq!(dest.layout.size.bits(), 256);
232-
233-
// Transmute to `[u128; 2]` to process each 128-bit chunk independently.
234-
let u128x2_layout =
235-
this.layout_of(Ty::new_array(this.tcx.tcx, this.tcx.types.u128, 2))?;
236-
let left = left.transmute(u128x2_layout, this)?;
237-
let right = right.transmute(u128x2_layout, this)?;
238-
let dest = dest.transmute(u128x2_layout, this)?;
239-
240-
let imm = this.read_scalar(imm)?.to_u8()?;
241-
242-
for i in 0..2 {
243-
let dest = this.project_index(&dest, i)?;
244-
245-
let imm = match i {
246-
0 => imm & 0xF,
247-
1 => imm >> 4,
248-
_ => unreachable!(),
249-
};
250-
if imm & 0b100 != 0 {
251-
this.write_scalar(Scalar::from_u128(0), &dest)?;
252-
} else {
253-
let src = match imm {
254-
0b00 => this.project_index(&left, 0)?,
255-
0b01 => this.project_index(&left, 1)?,
256-
0b10 => this.project_index(&right, 0)?,
257-
0b11 => this.project_index(&right, 1)?,
258-
_ => unreachable!(),
259-
};
260-
this.copy_op(&src, &dest)?;
261-
}
262-
}
263-
}
264220
// Used to implement the _mm_maskload_ps, _mm_maskload_pd, _mm256_maskload_ps
265221
// and _mm256_maskload_pd functions.
266222
// For the element `i`, if the high bit of the `i`-th element of `mask`

tests/pass/shims/x86/intrinsics-x86-avx.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -829,41 +829,44 @@ unsafe fn test_avx() {
829829

830830
#[target_feature(enable = "avx")]
831831
unsafe fn test_mm256_permute2f128_ps() {
832-
let a = _mm256_setr_ps(1., 2., 3., 4., 1., 2., 3., 4.);
833-
let b = _mm256_setr_ps(5., 6., 7., 8., 5., 6., 7., 8.);
834-
let r = _mm256_permute2f128_ps::<0x13>(a, b);
835-
let e = _mm256_setr_ps(5., 6., 7., 8., 1., 2., 3., 4.);
832+
let a = _mm256_setr_ps(11., 12., 13., 14., 15., 16., 17., 18.);
833+
let b = _mm256_setr_ps(21., 22., 23., 24., 25., 26., 27., 28.);
834+
let r = _mm256_permute2f128_ps::<0b0001_0011>(a, b);
835+
let e = _mm256_setr_ps(25., 26., 27., 28., 15., 16., 17., 18.);
836836
assert_eq_m256(r, e);
837837

838-
let r = _mm256_permute2f128_ps::<0x44>(a, b);
839-
let e = _mm256_setr_ps(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
840-
assert_eq_m256(r, e);
838+
// Setting bits 3 or 7 (zero-indexed) zeroes the corresponding field.
839+
let r = _mm256_permute2f128_ps::<0b1001_1011>(a, b);
840+
let z = _mm256_setr_ps(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
841+
assert_eq_m256(r, z);
841842
}
842843
test_mm256_permute2f128_ps();
843844

844845
#[target_feature(enable = "avx")]
845846
unsafe fn test_mm256_permute2f128_pd() {
846847
let a = _mm256_setr_pd(1., 2., 3., 4.);
847848
let b = _mm256_setr_pd(5., 6., 7., 8.);
848-
let r = _mm256_permute2f128_pd::<0x31>(a, b);
849+
let r = _mm256_permute2f128_pd::<0b0011_0001>(a, b);
849850
let e = _mm256_setr_pd(3., 4., 7., 8.);
850851
assert_eq_m256d(r, e);
851852

852-
let r = _mm256_permute2f128_pd::<0x44>(a, b);
853+
// Setting bits 3 or 7 (zero-indexed) zeroes the corresponding field.
854+
let r = _mm256_permute2f128_pd::<0b1011_1001>(a, b);
853855
let e = _mm256_setr_pd(0.0, 0.0, 0.0, 0.0);
854856
assert_eq_m256d(r, e);
855857
}
856858
test_mm256_permute2f128_pd();
857859

858860
#[target_feature(enable = "avx")]
859861
unsafe fn test_mm256_permute2f128_si256() {
860-
let a = _mm256_setr_epi32(1, 2, 3, 4, 1, 2, 3, 4);
861-
let b = _mm256_setr_epi32(5, 6, 7, 8, 5, 6, 7, 8);
862-
let r = _mm256_permute2f128_si256::<0x20>(a, b);
863-
let e = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8);
862+
let a = _mm256_setr_epi32(11, 12, 13, 14, 15, 16, 17, 18);
863+
let b = _mm256_setr_epi32(21, 22, 23, 24, 25, 26, 27, 28);
864+
let r = _mm256_permute2f128_si256::<0b0010_0000>(a, b);
865+
let e = _mm256_setr_epi32(11, 12, 13, 14, 21, 22, 23, 24);
864866
assert_eq_m256i(r, e);
865867

866-
let r = _mm256_permute2f128_si256::<0x44>(a, b);
868+
// Setting bits 3 or 7 (zero-indexed) zeroes the corresponding field.
869+
let r = _mm256_permute2f128_si256::<0b1010_1000>(a, b);
867870
let e = _mm256_setr_epi32(0, 0, 0, 0, 0, 0, 0, 0);
868871
assert_eq_m256i(r, e);
869872
}

tests/pass/shims/x86/intrinsics-x86-pause-without-sse2.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,5 @@ use std::arch::x86_64::*;
99

1010
fn main() {
1111
assert!(!is_x86_feature_detected!("sse2"));
12-
13-
unsafe {
14-
// This is a SSE2 intrinsic, but it behaves as a no-op when SSE2
15-
// is not available, so it is always safe to call.
16-
_mm_pause();
17-
}
12+
_mm_pause();
1813
}

tests/pass/shims/x86/intrinsics-x86-sse2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ unsafe fn test_sse2() {
5454
}
5555

5656
fn test_mm_pause() {
57-
unsafe { _mm_pause() }
57+
_mm_pause()
5858
}
5959
test_mm_pause();
6060

tests/pass/shims/x86/intrinsics-x86.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@ mod x86 {
77

88
fn adc(c_in: u8, a: u32, b: u32) -> (u8, u32) {
99
let mut sum = 0;
10-
// SAFETY: There are no safety requirements for calling `_addcarry_u32`.
11-
// It's just unsafe for API consistency with other intrinsics.
12-
let c_out = unsafe { arch::_addcarry_u32(c_in, a, b, &mut sum) };
10+
let c_out = arch::_addcarry_u32(c_in, a, b, &mut sum);
1311
(c_out, sum)
1412
}
1513

1614
fn sbb(b_in: u8, a: u32, b: u32) -> (u8, u32) {
1715
let mut sum = 0;
18-
// SAFETY: There are no safety requirements for calling `_subborrow_u32`.
19-
// It's just unsafe for API consistency with other intrinsics.
20-
let b_out = unsafe { arch::_subborrow_u32(b_in, a, b, &mut sum) };
16+
let b_out = arch::_subborrow_u32(b_in, a, b, &mut sum);
2117
(b_out, sum)
2218
}
2319

@@ -52,17 +48,13 @@ mod x86_64 {
5248

5349
fn adc(c_in: u8, a: u64, b: u64) -> (u8, u64) {
5450
let mut sum = 0;
55-
// SAFETY: There are no safety requirements for calling `_addcarry_u64`.
56-
// It's just unsafe for API consistency with other intrinsics.
57-
let c_out = unsafe { arch::_addcarry_u64(c_in, a, b, &mut sum) };
51+
let c_out = arch::_addcarry_u64(c_in, a, b, &mut sum);
5852
(c_out, sum)
5953
}
6054

6155
fn sbb(b_in: u8, a: u64, b: u64) -> (u8, u64) {
6256
let mut sum = 0;
63-
// SAFETY: There are no safety requirements for calling `_subborrow_u64`.
64-
// It's just unsafe for API consistency with other intrinsics.
65-
let b_out = unsafe { arch::_subborrow_u64(b_in, a, b, &mut sum) };
57+
let b_out = arch::_subborrow_u64(b_in, a, b, &mut sum);
6658
(b_out, sum)
6759
}
6860

0 commit comments

Comments
 (0)