On Tue, 28 Feb 2023 22:19:46 GMT, Sandhya Viswanathan 
<sviswanat...@openjdk.org> wrote:

>> Eirik Bjorsnos has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Use GE, LE, NE operations instead of the lt,not combinations. Use 
>> uppercase in vectorized code to match the scalar version.
>
> test/micro/org/openjdk/bench/jdk/incubator/vector/EqualsIgnoreCaseBenchmark.java
>  line 85:
> 
>> 83: 
>> 84:             // ASCII and Latin-1 were designed to optimize 
>> case-twiddling operations
>> 85:             ByteVector lowerA = va.or((byte) 0x20);
> 
> Just curious, here you use lower whereas in scalar code upper is being used. 
> Any reasons?

I can't remember the exact reason. Perhaps I thought I could get simpler range 
checking of the Latin-1 code points because they are almost at the end of the 
Latin-1 range.

I changed the vectorized version to use uppercase for better alignment with the 
scalar version.

> test/micro/org/openjdk/bench/jdk/incubator/vector/EqualsIgnoreCaseBenchmark.java
>  line 88:
> 
>> 86: 
>> 87:             // Determine which bytes represent ASCII or Latin-1 letters:
>> 88:             VectorMask<Byte> asciiLetter = lowerA.lt((byte) 
>> '{').and(lowerA.lt((byte) 0x60).not());
> 
> We do have GT/GE/NE etc comparison operators supported in Vector API, which 
> you can use here and other places in this benchmark. e.g.
> You could do lowerA.compare(GE, (byte)0x60) instead of using lt() followed 
> not(). BTW did you mean to use GT here?
> 
> You will need to do the following import:
> import static  jdk.incubator.vector.VectorOperators.*;

Thanks, that's a lot more readable! This checks that bytes are in the range => 
(byte) 'A', <= (byte) 'A', so I think this "not less than" was a poor man's 
compare(GE, (byte) 'A') here.

I've updated the code to use LE, GE, NE where appropriate

-------------

PR: https://git.openjdk.org/jdk/pull/12790

Reply via email to