From b29ffdf3fa289bdeb3de5ac0523d4d52df8d15bf Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 27 Mar 2020 10:04:42 -0700 Subject: [PATCH] Add missing packed comparisons to the scalar implementation of `I32x2` --- simd/src/scalar/mod.rs | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/simd/src/scalar/mod.rs b/simd/src/scalar/mod.rs index 5be22330..f2849355 100644 --- a/simd/src/scalar/mod.rs +++ b/simd/src/scalar/mod.rs @@ -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.