Skip to content

_mm256_cmpeq_epi8 returns a different result when -mattr=+avx2 #152

@MrcSnm

Description

@MrcSnm
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions