Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Sep 15, 2024
1 parent cebdfe4 commit 7ad353c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
CARGO_BUILD_INCREMENTAL: false
# Rust's CI denies warnings. Deny them here too to ensure subtree syncs don't
# fail because of warnings.
RUSTFLAGS: "-Dwarnings"
#RUSTFLAGS: "-Dwarnings"

jobs:
rustfmt:
Expand Down
25 changes: 25 additions & 0 deletions example/std_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ unsafe fn test_simd() {
test_mm_insert_epi16();
test_mm_shuffle_epi8();

test_mm_cmpestri();

test_mm256_shuffle_epi8();
test_mm256_permute2x128_si256();
test_mm256_permutevar8x32_epi32();
Expand Down Expand Up @@ -430,6 +432,29 @@ unsafe fn test_mm_shuffle_epi8() {
assert_eq_m128i(r, expected);
}

// Currently one cannot `load` a &[u8] that is less than 16
// in length. This makes loading strings less than 16 in length
// a bit difficult. Rather than `load` and mutate the __m128i,
// it is easier to memcpy the given string to a local slice with
// length 16 and `load` the local slice.
#[cfg(target_arch = "x86_64")]
#[target_feature(enable = "sse4.2")]
unsafe fn str_to_m128i(s: &[u8]) -> __m128i {
assert!(s.len() <= 16);
let slice = &mut [0u8; 16];
std::ptr::copy_nonoverlapping(s.as_ptr(), slice.as_mut_ptr(), s.len());
_mm_loadu_si128(slice.as_ptr() as *const _)
}

#[cfg(target_arch = "x86_64")]
#[target_feature(enable = "sse4.2")]
unsafe fn test_mm_cmpestri() {
let a = str_to_m128i(b"bar - garbage");
let b = str_to_m128i(b"foobar");
let i = _mm_cmpestri::<_SIDD_CMP_EQUAL_ORDERED>(a, 3, b, 6);
assert_eq!(3, i);
}

#[cfg(target_arch = "x86_64")]
#[target_feature(enable = "avx2")]
unsafe fn test_mm256_shuffle_epi8() {
Expand Down
2 changes: 2 additions & 0 deletions src/intrinsics/llvm_x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
let b = b.load_scalar(fx);
let lb = lb.load_scalar(fx);

panic!();

let imm8 =
if let Some(imm8) = crate::constant::mir_operand_get_const_val(fx, &args[4].node) {
imm8
Expand Down

0 comments on commit 7ad353c

Please sign in to comment.