Skip to content

Commit f1fa9d4

Browse files
authored
Rollup merge of rust-lang#56789 - alexcrichton:simd_select_bitmask, r=rkruppe
rustc: Add an unstable `simd_select_bitmask` intrinsic This is going to be required for binding a number of AVX-512 intrinsics in the `stdsimd` repository, and this intrinsic is the same as `simd_select` except that it takes a bitmask as the first argument instead of a SIMD vector. This bitmask is then transmuted into a `<NN x i8>` argument, depending on how many bits it is. cc rust-lang/stdarch#310
2 parents c269468 + ceee7f3 commit f1fa9d4

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/librustc_codegen_llvm/intrinsic.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ fn generic_simd_intrinsic(
11921192
return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate()));
11931193
}
11941194

1195-
// every intrinsic takes a SIMD vector as its first argument
1195+
// every intrinsic below takes a SIMD vector as its first argument
11961196
require_simd!(arg_tys[0], "input");
11971197
let in_ty = arg_tys[0];
11981198
let in_elem = arg_tys[0].simd_type(tcx);
@@ -1296,6 +1296,7 @@ fn generic_simd_intrinsic(
12961296
if name == "simd_select" {
12971297
let m_elem_ty = in_elem;
12981298
let m_len = in_len;
1299+
require_simd!(arg_tys[1], "argument");
12991300
let v_len = arg_tys[1].simd_size(tcx);
13001301
require!(m_len == v_len,
13011302
"mismatched lengths: mask length `{}` != other vector length `{}`",

src/test/ui/simd-intrinsic/simd-intrinsic-generic-select.rs

+6
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@ fn main() {
5454
simd_select(z, z, z);
5555
//~^ ERROR mask element type is `f32`, expected `i_`
5656

57+
simd_select(m4, 0u32, 1u32);
58+
//~^ ERROR found non-SIMD `u32`
59+
5760
simd_select_bitmask(0u8, x, x);
5861
//~^ ERROR mask length `8` != other vector length `4`
62+
//
63+
simd_select_bitmask(0u8, 1u32, 2u32);
64+
//~^ ERROR found non-SIMD `u32`
5965

6066
simd_select_bitmask(0.0f32, x, x);
6167
//~^ ERROR `f32` is not an integral type

src/test/ui/simd-intrinsic/simd-intrinsic-generic-select.stderr

+16-4
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,36 @@ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element
1616
LL | simd_select(z, z, z);
1717
| ^^^^^^^^^^^^^^^^^^^^
1818

19-
error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: mismatched lengths: mask length `8` != other vector length `4`
19+
error[E0511]: invalid monomorphization of `simd_select` intrinsic: expected SIMD argument type, found non-SIMD `u32`
2020
--> $DIR/simd-intrinsic-generic-select.rs:57:9
2121
|
22+
LL | simd_select(m4, 0u32, 1u32);
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
25+
error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: mismatched lengths: mask length `8` != other vector length `4`
26+
--> $DIR/simd-intrinsic-generic-select.rs:60:9
27+
|
2228
LL | simd_select_bitmask(0u8, x, x);
2329
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2430

31+
error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: expected SIMD argument type, found non-SIMD `u32`
32+
--> $DIR/simd-intrinsic-generic-select.rs:63:9
33+
|
34+
LL | simd_select_bitmask(0u8, 1u32, 2u32);
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36+
2537
error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: `f32` is not an integral type
26-
--> $DIR/simd-intrinsic-generic-select.rs:60:9
38+
--> $DIR/simd-intrinsic-generic-select.rs:66:9
2739
|
2840
LL | simd_select_bitmask(0.0f32, x, x);
2941
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3042

3143
error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: `&str` is not an integral type
32-
--> $DIR/simd-intrinsic-generic-select.rs:63:9
44+
--> $DIR/simd-intrinsic-generic-select.rs:69:9
3345
|
3446
LL | simd_select_bitmask("x", x, x);
3547
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3648

37-
error: aborting due to 6 previous errors
49+
error: aborting due to 8 previous errors
3850

3951
For more information about this error, try `rustc --explain E0511`.

0 commit comments

Comments
 (0)