<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div dir="ltr"><br></div><div dir="ltr">I believe your constructor of VectorShiftOr is not right. To be specific, in these lines:<div><br></div><div>    filter[low * 4] = filter[low] & mask;</div><div>    filter[upper * 4] = filter[upper] & mask;</div><div><br></div><div>The indices of the right-hand sides should be low * 4 and upper * 4, respectively. Additionally, a byte-to-int conversion is defaulted to be signed, so your load from the filter array should be filter[Byte.toUnsignedInt(ch)]. With that, I ran your benchmark on the head of openjdk/jdk and got these numbers:</div><div><br></div><div><div>Benchmark             Mode  Cnt         Score         Error  Units</div><div>ShiftOrBench.scalar  thrpt    5  29343807.339 ± 5317309.461  ops/s</div><div>ShiftOrBench.vector  thrpt    5  19713483.999 ± 1492701.034  ops/s</div></div><div><br></div><div>The slowdown relative to the scalar implementation is expected since the CPU can execute those instructions really efficiently, and vector operations only shine because they can perform on multiple inputs concurrently, as well as powerful cross-lane operations, both of which are absent from the benchmark.</div><div><br></div><div>With regards to the excessive materialisation of the flags, it has been fixed in mainline, and the code emitted would be</div><div><br></div><div>    vtestps %ymm4, %ymm4</div><div>    jne     0x00007fe668b696ac</div><div><br></div><div>Thanks,</div><div>Quan Anh</div></div></div></div></div>