@@ -2151,9 +2151,9 @@ internal static unsafe nuint WidenAsciiToUtf16(byte* pAsciiBuffer, char* pUtf16B
2151
2151
}
2152
2152
2153
2153
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
2154
- private static unsafe void WidenAsciiToUtf1_Vector< TVectorByte, TVectorUShort > ( byte * pAsciiBuffer , char * pUtf16Buffer , ref nuint currentOffset , nuint elementCount )
2154
+ private static unsafe void WidenAsciiToUtf1_Vector< TVectorByte, TVectorUInt16 > ( byte * pAsciiBuffer , char * pUtf16Buffer , ref nuint currentOffset , nuint elementCount )
2155
2155
where TVectorByte : unmanaged , ISimdVector < TVectorByte , byte >
2156
- where TVectorUShort : unmanaged , ISimdVector < TVectorUShort , ushort >
2156
+ where TVectorUInt16 : unmanaged , ISimdVector < TVectorUInt16 , ushort >
2157
2157
{
2158
2158
ushort * pCurrentWriteAddress = ( ushort * ) pUtf16Buffer;
2159
2159
// Calculating the destination address outside the loop results in significant
@@ -2163,14 +2163,14 @@ private static unsafe void WidenAsciiToUtf1_Vector<TVectorByte, TVectorUShort>(b
2163
2163
TVectorByte asciiVector = TVectorByte . Load ( pAsciiBuffer + currentOffset ) ;
2164
2164
if ( ! HasMatch < TVectorByte > ( asciiVector ) )
2165
2165
{
2166
- ( TVectorUShort utf16LowVector , TVectorUShort utf16HighVector ) = Widen < TVectorByte , TVectorUShort > ( asciiVector ) ;
2166
+ ( TVectorUInt16 utf16LowVector , TVectorUInt16 utf16HighVector ) = Widen < TVectorByte , TVectorUInt16 > ( asciiVector ) ;
2167
2167
utf16LowVector . Store ( pCurrentWriteAddress ) ;
2168
- utf16HighVector . Store ( pCurrentWriteAddress + TVectorUShort . Count ) ;
2169
- pCurrentWriteAddress += ( nuint ) ( TVectorUShort . Count * 2 ) ;
2170
- if ( ( ( int ) pCurrentWriteAddress & 1 ) == 0 )
2168
+ utf16HighVector . Store ( pCurrentWriteAddress + TVectorUInt16 . Count ) ;
2169
+ pCurrentWriteAddress += ( nuint ) ( TVectorUInt16 . Count * 2 ) ;
2170
+ if ( ( ( nuint ) pCurrentWriteAddress % sizeof ( char ) ) == 0 )
2171
2171
{
2172
2172
// Bump write buffer up to the next aligned boundary
2173
- pCurrentWriteAddress = ( ushort * ) ( ( nuint ) pCurrentWriteAddress & ~ ( nuint ) ( TVectorUShort . Alignment - 1 ) ) ;
2173
+ pCurrentWriteAddress = ( ushort * ) ( ( nuint ) pCurrentWriteAddress & ~ ( nuint ) ( TVectorUInt16 . Alignment - 1 ) ) ;
2174
2174
nuint numBytesWritten = ( nuint ) pCurrentWriteAddress - ( nuint ) pUtf16Buffer;
2175
2175
currentOffset += ( nuint ) numBytesWritten / 2 ;
2176
2176
}
@@ -2186,11 +2186,12 @@ private static unsafe void WidenAsciiToUtf1_Vector<TVectorByte, TVectorUShort>(b
2186
2186
{
2187
2187
break ;
2188
2188
}
2189
- ( utf16LowVector, utf16HighVector) = Widen< TVectorByte, TVectorUShort> ( asciiVector) ;
2190
- utf16LowVector. StoreAligned( pCurrentWriteAddress) ;
2191
- utf16HighVector. StoreAligned( pCurrentWriteAddress + TVectorUShort. Count) ;
2189
+ ( utf16LowVector, utf16HighVector) = Widen< TVectorByte, TVectorUInt16> ( asciiVector) ;
2190
+ utf16LowVector. Store( pCurrentWriteAddress) ;
2191
+ utf16HighVector. Store( pCurrentWriteAddress + TVectorUInt16. Count) ;
2192
+
2192
2193
currentOffset += ( nuint ) TVectorByte. Count;
2193
- pCurrentWriteAddress += ( nuint ) ( TVectorUShort . Count * 2 ) ;
2194
+ pCurrentWriteAddress += ( nuint ) ( TVectorUInt16 . Count * 2 ) ;
2194
2195
}
2195
2196
}
2196
2197
return ;
@@ -2205,22 +2206,26 @@ private static unsafe bool HasMatch<TVectorByte>(TVectorByte vector)
2205
2206
2206
2207
2207
2208
[ MethodImpl( MethodImplOptions. AggressiveInlining) ]
2208
- private static unsafe ( TVectorUShort Lower, TVectorUShort Upper ) Widen < TVectorByte, TVectorUShort > ( TVectorByte vector)
2209
+ private static unsafe ( TVectorUInt16 Lower, TVectorUInt16 Upper ) Widen < TVectorByte, TVectorUInt16 > ( TVectorByte vector)
2209
2210
where TVectorByte : unmanaged , ISimdVector < TVectorByte , byte >
2210
- where TVectorUShort : unmanaged , ISimdVector < TVectorUShort , ushort >
2211
+ where TVectorUInt16 : unmanaged , ISimdVector < TVectorUInt16 , ushort >
2211
2212
{
2212
2213
if ( typeof ( TVectorByte ) == typeof ( Vector256 < byte > ) )
2213
2214
{
2214
2215
( Vector256 < ushort > Lower256 , Vector256 < ushort > Upper256 ) = Vector256 . Widen ( ( Vector256 < byte > ) ( object ) vector) ;
2215
- return ( ( TVectorUShort ) ( object ) Lower256, ( TVectorUShort ) ( object ) Upper256) ;
2216
+ return ( ( TVectorUInt16 ) ( object ) Lower256, ( TVectorUInt16 ) ( object ) Upper256) ;
2216
2217
}
2217
2218
else if ( typeof ( TVectorByte ) == typeof ( Vector512 < byte > ) )
2218
2219
{
2219
2220
( Vector512 < ushort > Lower512 , Vector512 < ushort > Upper512 ) = Vector512 . Widen ( ( Vector512 < byte > ) ( object ) vector) ;
2220
- return ( ( TVectorUShort ) ( object ) Lower512, ( TVectorUShort ) ( object ) Upper512) ;
2221
+ return ( ( TVectorUInt16 ) ( object ) Lower512, ( TVectorUInt16 ) ( object ) Upper512) ;
2222
+ }
2223
+ else
2224
+ {
2225
+ Debug . Assert ( typeof ( TVectorByte ) == typeof ( Vector128 < byte > ) ) ;
2226
+ ( Vector128 < ushort > Lower128 , Vector128 < ushort > Upper128 ) = Vector128 . Widen ( ( Vector128 < byte > ) ( object ) vector) ;
2227
+ return ( ( TVectorUInt16 ) ( object ) Lower128, ( TVectorUInt16 ) ( object ) Upper128) ;
2221
2228
}
2222
- ( Vector128 < ushort > Lower128 , Vector128 < ushort > Upper128 ) = Vector128 . Widen ( ( Vector128 < byte > ) ( object ) vector) ;
2223
- return ( ( TVectorUShort ) ( object ) Lower128, ( TVectorUShort ) ( object ) Upper128) ;
2224
2229
}
2225
2230
2226
2231
0 commit comments