-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
import std.stdio;
import std.format;
import inteli.avx2intrin;
void main()
{
string a = `00000"00000""""""0000000000"""00`;
writeln = a.length;
byte32 chunk = cast(byte32)_mm256_loadu_si256(cast(__m256i*)a.ptr);
byte32 quoteMask = [0x22, 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,];
// ulong chunk = *cast(ulong*)a.ptr;
// enum quoteMask = 0x22_22_22_22_22_22_22_22;
// char[2] b = "1\"";
// enum quoteMask = 0x22_22;
// ushort chunk = *cast(ushort*)b.ptr;
// enum minus = 0x01_01;
// short quoteEq = cast(short)((chunk ^ quoteMask) - minus);
// import core.bitop;
// writeln = bsf(quoteEq & 0x8080) >> 3;
// writeln = format("%b", quoteEq & 0x8080);
import core.bitop;
// byte32 res = cast(byte32)_mm256_cmpeq_epi8(cast(long4)chunk, cast(long4)quoteMask); //results in 0... with +avx2
byte32 res = chunk == quoteMask; //only compares first 16 bytes if +avx2
int mask = _mm256_movemask_epi8(cast(long4)(res));
writeln = res;
writeln = format("%b", mask);
writeln = bsf(mask);
}PS: Using the == operator also results in a 3rd result. Basically, for byte32, it only compares the first 16 bytes