Skip to content

Use simd intrinsics for max and min#1357

Merged
Amanieu merged 1 commit intorust-lang:masterfrom
Nugine:simd_max_min
Nov 21, 2022
Merged

Use simd intrinsics for max and min#1357
Amanieu merged 1 commit intorust-lang:masterfrom
Nugine:simd_max_min

Conversation

@Nugine
Copy link
Contributor

@Nugine Nugine commented Nov 21, 2022

Copied from wasm32 implementaions

/// Compares lane-wise unsigned integers, and returns the maximum of
/// each pair.
#[inline]
#[cfg_attr(test, assert_instr(i8x16.max_u))]
#[target_feature(enable = "simd128")]
#[doc(alias("i8x16.max_u"))]
#[stable(feature = "wasm_simd", since = "1.54.0")]
pub fn u8x16_max(a: v128, b: v128) -> v128 {
let a = a.as_u8x16();
let b = b.as_u8x16();
unsafe { simd_select::<simd::i8x16, _>(simd_gt(a, b), a, b).v128() }
}

Affected functions:

sse2:

  • _mm_max_epi16
  • _mm_max_epu8
  • _mm_min_epi16
  • _mm_min_epu8

sse41:

  • _mm_max_epi8
  • _mm_max_epu16
  • _mm_max_epi32
  • _mm_max_epu32
  • _mm_min_epi8
  • _mm_min_epu16
  • _mm_min_epi32
  • _mm_min_epu32

avx2:

  • _mm256_max_epi16
  • _mm256_max_epi32
  • _mm256_max_epi8
  • _mm256_max_epu16
  • _mm256_max_epu32
  • _mm256_max_epu8
  • _mm256_min_epi16
  • _mm256_min_epi32
  • _mm256_min_epi8
  • _mm256_min_epu16
  • _mm256_min_epu32
  • _mm256_min_epu8

@rust-highfive
Copy link

r? @Amanieu

(rust-highfive has picked a reviewer for you, use r? to override)

@Amanieu Amanieu merged commit 32d6def into rust-lang:master Nov 21, 2022
@Nugine Nugine deleted the simd_max_min branch November 22, 2022 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants