diff --git a/Sources/_CollectionsUtilities/IntegerTricks/Integer rank.swift.gyb b/Sources/_CollectionsUtilities/IntegerTricks/Integer rank.swift.gyb index de75e1f7..59ad49ed 100644 --- a/Sources/_CollectionsUtilities/IntegerTricks/Integer rank.swift.gyb +++ b/Sources/_CollectionsUtilities/IntegerTricks/Integer rank.swift.gyb @@ -41,13 +41,16 @@ extension UInt { var shift: Self = 0 var n = Self(truncatingIfNeeded: n) - if Self.bitWidth == 64 { + if MemoryLayout.size == 8 { let c32 = (self & 0xFFFFFFFF)._nonzeroBitCount if n >= c32 { shift &+= 32 n &-= c32 } + } else { + assert(MemoryLayout.size == 4, "Unknown platform") } + let c16 = ((self &>> shift) & 0xFFFF)._nonzeroBitCount if n >= c16 { shift &+= 16 diff --git a/Sources/_CollectionsUtilities/IntegerTricks/autogenerated/Integer rank.swift b/Sources/_CollectionsUtilities/IntegerTricks/autogenerated/Integer rank.swift index 02790d35..07ede453 100644 --- a/Sources/_CollectionsUtilities/IntegerTricks/autogenerated/Integer rank.swift +++ b/Sources/_CollectionsUtilities/IntegerTricks/autogenerated/Integer rank.swift @@ -47,13 +47,16 @@ extension UInt { var shift: Self = 0 var n = Self(truncatingIfNeeded: n) - if Self.bitWidth == 64 { + if MemoryLayout.size == 8 { let c32 = (self & 0xFFFFFFFF)._nonzeroBitCount if n >= c32 { shift &+= 32 n &-= c32 } + } else { + assert(MemoryLayout.size == 4, "Unknown platform") } + let c16 = ((self &>> shift) & 0xFFFF)._nonzeroBitCount if n >= c16 { shift &+= 16 @@ -184,13 +187,16 @@ extension UInt { var shift: Self = 0 var n = Self(truncatingIfNeeded: n) - if Self.bitWidth == 64 { + if MemoryLayout.size == 8 { let c32 = (self & 0xFFFFFFFF)._nonzeroBitCount if n >= c32 { shift &+= 32 n &-= c32 } + } else { + assert(MemoryLayout.size == 4, "Unknown platform") } + let c16 = ((self &>> shift) & 0xFFFF)._nonzeroBitCount if n >= c16 { shift &+= 16