Skip to content

Commit 69e75f4

Browse files
authored
Rollup merge of #137953 - RalfJung:simd-intrinsic-masks, r=WaffleLapkin
simd intrinsics with mask: accept unsigned integer masks, and fix some of the errors It's not clear at all why the mask would have to be signed, it is anyway interpreted bitwise. The backend should just make sure that works no matter the surface-level type; our LLVM backend already does this correctly. The note of "the mask may be widened, which only has the correct behavior for signed integers" explains... nothing? Why can't the code do the widening correctly? If necessary, just cast to the signed type first... Also while we are at it, fix the errors. For simd_masked_load/store, the errors talked about the "third argument" but they meant the first argument (the mask is the first argument there). They also used the wrong type for `expected_element`. I have extremely low confidence in the GCC part of this PR. See [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/257879-project-portable-simd/topic/On.20the.20sign.20of.20masks)
2 parents 5f4afd8 + e4ec127 commit 69e75f4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/helpers.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,11 @@ pub(crate) fn bool_to_simd_element(b: bool, size: Size) -> Scalar {
13821382
}
13831383

13841384
pub(crate) fn simd_element_to_bool(elem: ImmTy<'_>) -> InterpResult<'_, bool> {
1385+
assert!(
1386+
matches!(elem.layout.ty.kind(), ty::Int(_) | ty::Uint(_)),
1387+
"SIMD mask element type must be an integer, but this is `{}`",
1388+
elem.layout.ty
1389+
);
13851390
let val = elem.to_scalar().to_int(elem.layout.size)?;
13861391
interp_ok(match val {
13871392
0 => false,

0 commit comments

Comments
 (0)