Add missing packed comparisons to the scalar implementation of `I32x2`

This commit is contained in:
Patrick Walton 2020-03-27 10:04:42 -07:00
parent 55df287fec
commit b29ffdf3fa
1 changed files with 34 additions and 8 deletions

View File

@ -478,14 +478,6 @@ impl I32x2 {
self[1]
}
#[inline]
pub fn packed_eq(self, other: I32x2) -> U32x2 {
U32x2([
if self[0] == other[0] { !0 } else { 0 },
if self[1] == other[1] { !0 } else { 0 },
])
}
#[inline]
pub fn concat_xy_xy(self, other: I32x2) -> I32x4 {
I32x4([self[0], self[1], other[0], other[1]])
@ -507,6 +499,40 @@ impl I32x2 {
])
}
// Packed comparisons
#[inline]
pub fn packed_eq(self, other: I32x2) -> U32x2 {
U32x2([
if self[0] == other[0] { !0 } else { 0 },
if self[1] == other[1] { !0 } else { 0 },
])
}
#[inline]
pub fn packed_gt(self, other: I32x2) -> U32x2 {
U32x2([
if self[0] > other[0] { !0 } else { 0 },
if self[1] > other[1] { !0 } else { 0 },
])
}
#[inline]
pub fn packed_le(self, other: I32x2) -> U32x2 {
U32x2([
if self[0] <= other[0] { !0 } else { 0 },
if self[1] <= other[1] { !0 } else { 0 },
])
}
#[inline]
pub fn packed_lt(self, other: I32x2) -> U32x2 {
U32x2([
if self[0] < other[0] { !0 } else { 0 },
if self[1] < other[1] { !0 } else { 0 },
])
}
// Conversions
/// Converts these packed integers to floats.