Skip to content

Rollup of 10 pull requests #140547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
cf26d82
chore: remove redundant words in comment
pudongair Mar 26, 2025
d81559a
Refactor `diy_float`
TDecking Mar 31, 2025
5a20701
Change signature of File::try_lock and File::try_lock_shared
cberner Apr 4, 2025
7302f8e
Implement error::Error for TryLockError
cberner Apr 6, 2025
e5fb426
docs: Add example to `Iterator::take` with `by_ref`
ongardie Apr 14, 2025
0369ccb
Fix some grammar errors and hyperlinks in doc for `trait Allocator`
Lee-Janggun Apr 14, 2025
31cb737
simd_select_bitmask: the 'padding' bits in the mask are just ignored
RalfJung Apr 19, 2025
3a372e3
std: mention `remove_dir_all` can emit `DirectoryNotEmpty` when concu…
xizheyin Apr 20, 2025
e9d2fef
stop check paren if has different ctx
bvanjoi Apr 29, 2025
d9c060b
Optimize the codegen for `Span::from_expansion`
Jarcho Apr 29, 2025
00f25a8
interpret: better error message for out-of-bounds pointer arithmetic …
RalfJung Apr 30, 2025
64ba474
Rollup merge of #134034 - bvanjoi:issue-131655, r=petrochenkov
Zalathar May 1, 2025
a5ffdb8
Rollup merge of #138703 - pudongair:master, r=workingjubilee
Zalathar May 1, 2025
b06dbd0
Rollup merge of #139186 - TDecking:float, r=workingjubilee
Zalathar May 1, 2025
485270d
Rollup merge of #139343 - cberner:filelock_wouldblock, r=workingjubilee
Zalathar May 1, 2025
76fa362
Rollup merge of #139780 - ongardie:iterator-take-by_ref-example, r=wo…
Zalathar May 1, 2025
a471fe9
Rollup merge of #139802 - Lee-Janggun:fix-allocate-hyperlink, r=worki…
Zalathar May 1, 2025
c4da0f3
Rollup merge of #140034 - RalfJung:simd_select_bitmask-padding, r=wor…
Zalathar May 1, 2025
5d78430
Rollup merge of #140062 - xizheyin:issue-139958, r=workingjubilee
Zalathar May 1, 2025
ca45af0
Rollup merge of #140485 - Jarcho:from_expansion_opt, r=petrochenkov
Zalathar May 1, 2025
582dbdd
Rollup merge of #140521 - RalfJung:oob-error, r=saethlin
Zalathar May 1, 2025
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
4 changes: 1 addition & 3 deletions library/core/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,9 @@ pub unsafe fn simd_select<M, T>(mask: M, if_true: T, if_false: T) -> T;
/// For each element, if the bit in `mask` is `1`, select the element from
/// `if_true`. If the corresponding bit in `mask` is `0`, select the element from
/// `if_false`.
/// The remaining bits of the mask are ignored.
///
/// The bitmask bit order matches `simd_bitmask`.
///
/// # Safety
/// Padding bits must be all zero.
#[rustc_intrinsic]
#[rustc_nounwind]
pub unsafe fn simd_select_bitmask<M, T>(m: M, yes: T, no: T) -> T;
Expand Down
13 changes: 1 addition & 12 deletions src/tools/miri/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
};

let dest_len = u32::try_from(dest_len).unwrap();
let bitmask_len = u32::try_from(bitmask_len).unwrap();
for i in 0..dest_len {
let bit_i = simd_bitmask_index(i, dest_len, this.data_layout().endian);
let mask = mask & 1u64.strict_shl(bit_i);
Expand All @@ -517,17 +516,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let val = if mask != 0 { yes } else { no };
this.write_immediate(*val, &dest)?;
}
for i in dest_len..bitmask_len {
// If the mask is "padded", ensure that padding is all-zero.
// This deliberately does not use `simd_bitmask_index`; these bits are outside
// the bitmask. It does not matter in which order we check them.
let mask = mask & 1u64.strict_shl(i);
if mask != 0 {
throw_ub_format!(
"a SIMD bitmask less than 8 bits long must be filled with 0s for the remaining bits"
);
}
}
// The remaining bits of the mask are ignored.
}
// Converts a "vector of bool" into a bitmask.
"bitmask" => {
Expand Down

This file was deleted.

This file was deleted.

13 changes: 13 additions & 0 deletions src/tools/miri/tests/pass/intrinsics/portable-simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,19 @@ fn simd_mask() {
);
assert_eq!(selected1, i32x4::from_array([0, 0, 0, 1]));
assert_eq!(selected2, selected1);
// Non-zero "padding" (the extra bits) is also allowed.
let selected1 = simd_select_bitmask::<u8, _>(
if cfg!(target_endian = "little") { 0b11111000 } else { 0b11110001 },
i32x4::splat(1), // yes
i32x4::splat(0), // no
);
let selected2 = simd_select_bitmask::<[u8; 1], _>(
if cfg!(target_endian = "little") { [0b11111000] } else { [0b11110001] },
i32x4::splat(1), // yes
i32x4::splat(0), // no
);
assert_eq!(selected1, i32x4::from_array([0, 0, 0, 1]));
assert_eq!(selected2, selected1);
}

// Non-power-of-2 multi-byte mask.
Expand Down