Support vectors with fewer than 8 elements for simd_select_bitmask
This commit is contained in:
parent
6f56fbdc1c
commit
e41a14412e
4 changed files with 37 additions and 8 deletions
|
@ -793,14 +793,18 @@ fn generic_simd_intrinsic(
|
||||||
require_simd!(arg_tys[1], "argument");
|
require_simd!(arg_tys[1], "argument");
|
||||||
let v_len = arg_tys[1].simd_size(tcx);
|
let v_len = arg_tys[1].simd_size(tcx);
|
||||||
require!(
|
require!(
|
||||||
m_len == v_len,
|
// Allow masks for vectors with fewer than 8 elements to be
|
||||||
|
// represented with a u8 or i8.
|
||||||
|
m_len == v_len || (m_len == 8 && v_len < 8),
|
||||||
"mismatched lengths: mask length `{}` != other vector length `{}`",
|
"mismatched lengths: mask length `{}` != other vector length `{}`",
|
||||||
m_len,
|
m_len,
|
||||||
v_len
|
v_len
|
||||||
);
|
);
|
||||||
let i1 = bx.type_i1();
|
let i1 = bx.type_i1();
|
||||||
let i1xn = bx.type_vector(i1, m_len);
|
let im = bx.type_ix(v_len);
|
||||||
let m_i1s = bx.bitcast(args[0].immediate(), i1xn);
|
let i1xn = bx.type_vector(i1, v_len);
|
||||||
|
let m_im = bx.trunc(args[0].immediate(), im);
|
||||||
|
let m_i1s = bx.bitcast(m_im, i1xn);
|
||||||
return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate()));
|
return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,8 @@ fn main() {
|
||||||
simd_select(m4, 0u32, 1u32);
|
simd_select(m4, 0u32, 1u32);
|
||||||
//~^ ERROR found non-SIMD `u32`
|
//~^ ERROR found non-SIMD `u32`
|
||||||
|
|
||||||
simd_select_bitmask(0u8, x, x);
|
simd_select_bitmask(0u16, x, x);
|
||||||
//~^ ERROR mask length `8` != other vector length `4`
|
//~^ ERROR mask length `16` != other vector length `4`
|
||||||
//
|
//
|
||||||
simd_select_bitmask(0u8, 1u32, 2u32);
|
simd_select_bitmask(0u8, 1u32, 2u32);
|
||||||
//~^ ERROR found non-SIMD `u32`
|
//~^ ERROR found non-SIMD `u32`
|
||||||
|
|
|
@ -22,11 +22,11 @@ error[E0511]: invalid monomorphization of `simd_select` intrinsic: expected SIMD
|
||||||
LL | simd_select(m4, 0u32, 1u32);
|
LL | simd_select(m4, 0u32, 1u32);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: mismatched lengths: mask length `8` != other vector length `4`
|
error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: mismatched lengths: mask length `16` != other vector length `4`
|
||||||
--> $DIR/simd-intrinsic-generic-select.rs:52:9
|
--> $DIR/simd-intrinsic-generic-select.rs:52:9
|
||||||
|
|
|
|
||||||
LL | simd_select_bitmask(0u8, x, x);
|
LL | simd_select_bitmask(0u16, x, x);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: expected SIMD argument type, found non-SIMD `u32`
|
error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: expected SIMD argument type, found non-SIMD `u32`
|
||||||
--> $DIR/simd-intrinsic-generic-select.rs:55:9
|
--> $DIR/simd-intrinsic-generic-select.rs:55:9
|
||||||
|
|
|
@ -167,4 +167,29 @@ fn main() {
|
||||||
let e = u32x8(8, 9, 10, 11, 4, 5, 6, 7);
|
let e = u32x8(8, 9, 10, 11, 4, 5, 6, 7);
|
||||||
assert_eq!(r, e);
|
assert_eq!(r, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
let a = u32x4(0, 1, 2, 3);
|
||||||
|
let b = u32x4(4, 5, 6, 7);
|
||||||
|
|
||||||
|
let r: u32x4 = simd_select_bitmask(0u8, a, b);
|
||||||
|
let e = b;
|
||||||
|
assert_eq!(r, e);
|
||||||
|
|
||||||
|
let r: u32x4 = simd_select_bitmask(0xfu8, a, b);
|
||||||
|
let e = a;
|
||||||
|
assert_eq!(r, e);
|
||||||
|
|
||||||
|
let r: u32x4 = simd_select_bitmask(0b0101u8, a, b);
|
||||||
|
let e = u32x4(0, 5, 2, 7);
|
||||||
|
assert_eq!(r, e);
|
||||||
|
|
||||||
|
let r: u32x4 = simd_select_bitmask(0b1010u8, a, b);
|
||||||
|
let e = u32x4(4, 1, 6, 3);
|
||||||
|
assert_eq!(r, e);
|
||||||
|
|
||||||
|
let r: u32x4 = simd_select_bitmask(0b1100u8, a, b);
|
||||||
|
let e = u32x4(4, 5, 2, 3);
|
||||||
|
assert_eq!(r, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue