Add min/max to i32x2.

This commit is contained in:
Josh Matthews 2020-04-07 12:42:28 -04:00 committed by GitHub
parent db205f71d6
commit e87b330123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -445,6 +445,18 @@ impl I32x2 {
unsafe { U32x2(simd_eq(self.0, other.0)) } unsafe { U32x2(simd_eq(self.0, other.0)) }
} }
// Basic operations
#[inline]
pub fn max(self, other: I32x2) -> I32x2 {
self.to_i32x4().max(other.to_i32x4()).xy()
}
#[inline]
pub fn min(self, other: I32x2) -> I32x2 {
self.to_i32x4().min(other.to_i32x4()).xy()
}
// Concatenations // Concatenations
#[inline] #[inline]
@ -459,6 +471,11 @@ impl I32x2 {
pub fn to_f32x2(self) -> F32x2 { pub fn to_f32x2(self) -> F32x2 {
unsafe { F32x2(simd_cast(self.0)) } unsafe { F32x2(simd_cast(self.0)) }
} }
#[inline]
pub fn to_i32x4(self) -> I32x4 {
self.concat_xy_xy(I32x2::default())
}
} }
impl Default for I32x2 { impl Default for I32x2 {