RFR: 8276162: Optimise unsigned comparison pattern [v2]

Mai Đặng Quân Anh duke at openjdk.java.net
Thu Nov 11 05:16:34 UTC 2021


On Wed, 10 Nov 2021 20:36:55 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> Mai Đặng Quân Anh has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   fix copyright declaration
>
> src/hotspot/share/opto/subnode.cpp line 1542:
> 
>> 1540:       phase->type(cmp1->in(2)) == TypeInt::MIN) {
>> 1541:     if (cmp2_op == Op_ConI) {
>> 1542:       Node *ncmp2 = phase->intcon(java_add(cmp2->get_int(), min_jint));
> 
> What if `cmp1_op == Op_SubI` ?

Since `x + MIN_VALUE == x - MIN_VALUE`, the operation is the same with addition and subtraction operations. However, I realised that `x - MIN_VALUE` is idealised into `x + MIN_VALUE` beforehand, so I have removed the check for `Op_SubI` here.

> test/micro/org/openjdk/bench/vm/compiler/UnsignedComparison.java line 43:
> 
>> 41:     public long compareLong(long arg0, long arg1) {
>> 42:         return arg0 + Long.MIN_VALUE < arg1 + Long.MIN_VALUE ? 1 : 0;
>> 43:     }
> 
> Add tests for subtraction.

Since I have removed the subtraction circumstances, do we still need tests for them here.
Thank you very much.

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

PR: https://git.openjdk.java.net/jdk/pull/6101


More information about the hotspot-compiler-dev mailing list