Skip to content

Commit 0c89d6d

Browse files
committed
cg_llvm: scalable vectors with simd_select
Building on the previous change, support scalable vectors with `simd_select`. Previous patches already landed the necessary changes in the implementation of this intrinsic, but didn't allow scalable vector arguments to be passed in.
1 parent 66c783d commit 0c89d6d

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
17841784
}
17851785

17861786
let supports_scalable = match name {
1787-
sym::simd_cast => true,
1787+
sym::simd_cast | sym::simd_select => true,
17881788
_ => false,
17891789
};
17901790

@@ -1984,7 +1984,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
19841984
if name == sym::simd_select {
19851985
let m_elem_ty = in_elem;
19861986
let m_len = in_len;
1987-
let (v_len, _) = require_simd!(args[1].layout.ty, SimdArgument);
1987+
let (v_len, _, _) = require_simd_or_scalable!(args[1].layout.ty, SimdArgument);
19881988
require!(
19891989
m_len == v_len,
19901990
InvalidMonomorphization::MismatchedLengths { span, name, m_len, v_len }
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ check-pass
2+
//@ only-aarch64
3+
#![crate_type = "lib"]
4+
#![allow(incomplete_features, internal_features, improper_ctypes)]
5+
#![feature(abi_unadjusted, core_intrinsics, link_llvm_intrinsics, rustc_attrs)]
6+
7+
use std::intrinsics::simd::simd_select;
8+
9+
#[derive(Copy, Clone)]
10+
#[rustc_scalable_vector(16)]
11+
#[allow(non_camel_case_types)]
12+
pub struct svbool_t(bool);
13+
14+
#[derive(Copy, Clone)]
15+
#[rustc_scalable_vector(16)]
16+
#[allow(non_camel_case_types)]
17+
pub struct svint8_t(i8);
18+
19+
#[target_feature(enable = "sve")]
20+
pub fn svsel_s8(pg: svbool_t, op1: svint8_t, op2: svint8_t) -> svint8_t {
21+
unsafe { simd_select::<svbool_t, _>(pg, op1, op2) }
22+
}

0 commit comments

Comments
 (0)