On Tue, 29 Mar 2022 02:24:21 GMT, Jatin Bhateja <jbhat...@openjdk.org> wrote:

>> Implements x86 intrinsics for compare() method in java.lang.Integer and 
>> java.lang.Long.
>
> src/hotspot/cpu/x86/x86_64.ad line 12107:
> 
>> 12105: instruct compareSignedI_rReg(rRegI dst, rRegI op1, rRegI op2, rRegI 
>> tmp, rFlagsReg cr)
>> 12106: %{
>> 12107:   match(Set dst (CompareSignedI op1 op2));
> 
> Please also include these patterns in x86_32.ad

Will update x86_32.ad as well.

> src/hotspot/cpu/x86/x86_64.ad line 12125:
> 
>> 12123:         __ movl(tmp, 0);
>> 12124:     __ bind(done);
>> 12125:     __ movl(dest, tmp);
> 
> Please move this in macro-assembly routine.

Sure, will refactor it into a macro-assembly

> src/hotspot/cpu/x86/x86_64.ad line 12178:
> 
>> 12176:         __ movl(tmp, 0);
>> 12177:     __ bind(done);
>> 12178:     __ movl(dest, tmp);
> 
> Please move this into a macro-assembly routine.

Sure, will do that and update it soon.

> src/hotspot/cpu/x86/x86_64.ad line 12204:
> 
>> 12202:         __ movl(tmp, 0);
>> 12203:     __ bind(done);
>> 12204:     __ movl(dest, tmp);
> 
> Please move this into macro-assembly routine.

Sure, will do that and update it soon.

> src/hotspot/share/opto/comparenode.hpp line 67:
> 
>> 65:     CompareUnsignedLNode(Node* in1, Node* in2) : CompareNode(in1, in2) {}
>> 66:     virtual int Opcode() const;
>> 67: };
> 
> Intent here seems to be to enable further auto-vectorization of newly create 
> IR nodes.

Yes, that is the intention.

> test/micro/org/openjdk/bench/java/lang/CompareInteger.java line 78:
> 
>> 76:                     input2[i] = tmp;
>> 77:                 }
>> 78:             }
> 
> Logic re-organization suggestion:- 
>  
> 
>  for (int i = 0 ; i < BUFFER_SIZE; i++) {
>     input1[i] = rng.nextLong();
>  }
> 
>  if (mode.equals("equals") {
>     GRADIANT = 0;
>  } else if (mode.equals("greaterThanEquals")) {
>     GRADIANT = 1;
>  } else {
>     assert mode.equals("lessThanEqual");
>     GRADIANT = -1;
>  }
> 
>  for(int i = 0 ; i < BUFFER_SIZE; i++) {
>     input2[i] = input1[i] + i*GRADIANT;
>  }

The suggested refactoring is definitely elegant but one rare possibility is 
overflow due to the addition/subtraction. The swap logic doesn't have that 
problem.

> test/micro/org/openjdk/bench/java/lang/CompareLong.java line 5:
> 
>> 3:  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
>> 4:  *
>> 5:  * This code is free software; you can redistribute it and/or modify it
> 
> We can unify this benchmark along with integer compare micro.

Sure, will do the unification.

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

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

Reply via email to