Skip to content

Commit 1cbc39f

Browse files
bjorn3gnzlbg
authored andcommitted
Use simd_floor and simd_ceil where possible
1 parent 3a56a17 commit 1cbc39f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

crates/core_arch/src/simd_llvm.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,7 @@ extern "platform-intrinsic" {
6161
pub fn simd_fmax<T>(a: T, b: T) -> T;
6262

6363
pub fn simd_fsqrt<T>(a: T) -> T;
64+
pub fn simd_floor<T>(a: T) -> T;
65+
pub fn simd_ceil<T>(a: T) -> T;
6466
pub fn simd_fma<T>(a: T, b: T, c: T) -> T;
6567
}

crates/core_arch/src/x86/avx.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ pub unsafe fn _mm256_round_pd(a: __m256d, b: i32) -> __m256d {
426426
#[cfg_attr(test, assert_instr(vroundpd))]
427427
#[stable(feature = "simd_x86", since = "1.27.0")]
428428
pub unsafe fn _mm256_ceil_pd(a: __m256d) -> __m256d {
429-
roundpd256(a, 0x02)
429+
simd_ceil(a)
430430
}
431431

432432
/// Rounds packed double-precision (64-bit) floating point elements in `a`
@@ -438,7 +438,7 @@ pub unsafe fn _mm256_ceil_pd(a: __m256d) -> __m256d {
438438
#[cfg_attr(test, assert_instr(vroundpd))]
439439
#[stable(feature = "simd_x86", since = "1.27.0")]
440440
pub unsafe fn _mm256_floor_pd(a: __m256d) -> __m256d {
441-
roundpd256(a, 0x01)
441+
simd_floor(a)
442442
}
443443

444444
/// Rounds packed single-precision (32-bit) floating point elements in `a`
@@ -477,7 +477,7 @@ pub unsafe fn _mm256_round_ps(a: __m256, b: i32) -> __m256 {
477477
#[cfg_attr(test, assert_instr(vroundps))]
478478
#[stable(feature = "simd_x86", since = "1.27.0")]
479479
pub unsafe fn _mm256_ceil_ps(a: __m256) -> __m256 {
480-
roundps256(a, 0x02)
480+
simd_ceil(a)
481481
}
482482

483483
/// Rounds packed single-precision (32-bit) floating point elements in `a`
@@ -489,7 +489,7 @@ pub unsafe fn _mm256_ceil_ps(a: __m256) -> __m256 {
489489
#[cfg_attr(test, assert_instr(vroundps))]
490490
#[stable(feature = "simd_x86", since = "1.27.0")]
491491
pub unsafe fn _mm256_floor_ps(a: __m256) -> __m256 {
492-
roundps256(a, 0x01)
492+
simd_floor(a)
493493
}
494494

495495
/// Returns the square root of packed single-precision (32-bit) floating point

0 commit comments

Comments
 (0)