Re: RFR: 8282221: x86 intrinsics for divideUnsigned and remainderUnsigned methods in java.lang.Integer and java.lang.Long [v12]

2022-04-08 Thread Vladimir Kozlov
On Fri, 8 Apr 2022 18:32:06 GMT, Sandhya Viswanathan  
wrote:

> My suggestion is to keep the -ve path assembly optimization in this patch.
> When the optimization in IR is introduced, the assembly could then be 
> simplified as suggested by @merykitty.

Okay. Lets do that as part of JDK-8282365.

-

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


Re: RFR: 8282221: x86 intrinsics for divideUnsigned and remainderUnsigned methods in java.lang.Integer and java.lang.Long [v12]

2022-04-08 Thread Sandhya Viswanathan
On Fri, 8 Apr 2022 01:05:33 GMT, Srinivas Vamsi Parasa  
wrote:

>> Optimizes the divideUnsigned() and remainderUnsigned() methods in 
>> java.lang.Integer and java.lang.Long classes using x86 intrinsics. This 
>> change shows 3x improvement for Integer methods and upto 25% improvement for 
>> Long. This change also implements the DivMod optimization which fuses 
>> division and modulus operations if needed. The DivMod optimization shows 3x 
>> improvement for Integer and ~65% improvement for Long.
>
> Srinivas Vamsi Parasa has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   uncomment zero in integer div, mod test

My suggestion is to keep the -ve path assembly optimization in this patch.
When the optimization in IR is introduced, the assembly could then be 
simplified as suggested by @merykitty.

-

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


Re: RFR: 8282221: x86 intrinsics for divideUnsigned and remainderUnsigned methods in java.lang.Integer and java.lang.Long [v12]

2022-04-08 Thread Vladimir Kozlov
On Fri, 8 Apr 2022 01:05:33 GMT, Srinivas Vamsi Parasa  
wrote:

>> Optimizes the divideUnsigned() and remainderUnsigned() methods in 
>> java.lang.Integer and java.lang.Long classes using x86 intrinsics. This 
>> change shows 3x improvement for Integer methods and upto 25% improvement for 
>> Long. This change also implements the DivMod optimization which fuses 
>> division and modulus operations if needed. The DivMod optimization shows 3x 
>> improvement for Integer and ~65% improvement for Long.
>
> Srinivas Vamsi Parasa has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   uncomment zero in integer div, mod test

Agree, this is reasonable suggestion. It could be done in these changes.

-

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


Re: RFR: 8282221: x86 intrinsics for divideUnsigned and remainderUnsigned methods in java.lang.Integer and java.lang.Long [v12]

2022-04-08 Thread Vladimir Kozlov
On Fri, 8 Apr 2022 01:59:10 GMT, Quan Anh Mai  wrote:

> Personally, I think the optimisation for `div < 0` should be handled by the 
> mid-end optimiser, which will not only give us the advantages of dead code 
> elimination, but also global code motion. I would suggest the backend only 
> doing `xorl rdx, rdx; divl $div$$Register` and the optimisation for `div < 0` 
> will be implemented as a part of JDK-8282365. What do you think?

 I agree that we can do more optimizations with constants as JDK-8282365 
suggested.

But I think we should proceed with current changes as they are after fixing 
remaining issues.
I assume that you are talking about case when `divisor` is constant (or both). 
Because if it is not, IR optimization will not help - we don't profile 
arithmetic values so we can't generate uncommon trap path without some 
profiling information.

-

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


Re: RFR: 8282221: x86 intrinsics for divideUnsigned and remainderUnsigned methods in java.lang.Integer and java.lang.Long [v12]

2022-04-07 Thread Quan Anh Mai
On Fri, 8 Apr 2022 01:05:33 GMT, Srinivas Vamsi Parasa  
wrote:

>> Optimizes the divideUnsigned() and remainderUnsigned() methods in 
>> java.lang.Integer and java.lang.Long classes using x86 intrinsics. This 
>> change shows 3x improvement for Integer methods and upto 25% improvement for 
>> Long. This change also implements the DivMod optimization which fuses 
>> division and modulus operations if needed. The DivMod optimization shows 3x 
>> improvement for Integer and ~65% improvement for Long.
>
> Srinivas Vamsi Parasa has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   uncomment zero in integer div, mod test

Personally, I think the optimisation for `div < 0` should be handled by the 
mid-end optimiser, which will not only give us the advantages of dead code 
elimination, but also global code motion. I would suggest the backend only 
doing `xorl rdx, rdx; divl $div$$Register` and the optimisation for `div < 0` 
will be implemented as a part of JDK-8282365. What do you think?
Thanks.

-

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


Re: RFR: 8282221: x86 intrinsics for divideUnsigned and remainderUnsigned methods in java.lang.Integer and java.lang.Long [v12]

2022-04-07 Thread Vladimir Kozlov
On Fri, 8 Apr 2022 01:05:33 GMT, Srinivas Vamsi Parasa  
wrote:

>> Optimizes the divideUnsigned() and remainderUnsigned() methods in 
>> java.lang.Integer and java.lang.Long classes using x86 intrinsics. This 
>> change shows 3x improvement for Integer methods and upto 25% improvement for 
>> Long. This change also implements the DivMod optimization which fuses 
>> division and modulus operations if needed. The DivMod optimization shows 3x 
>> improvement for Integer and ~65% improvement for Long.
>
> Srinivas Vamsi Parasa has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   uncomment zero in integer div, mod test

Good. I forgot before to ask about how you handle devision by 0 and now you 
added check for it.

Let me run testing before approval.

-

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


Re: RFR: 8282221: x86 intrinsics for divideUnsigned and remainderUnsigned methods in java.lang.Integer and java.lang.Long [v12]

2022-04-07 Thread Srinivas Vamsi Parasa
> Optimizes the divideUnsigned() and remainderUnsigned() methods in 
> java.lang.Integer and java.lang.Long classes using x86 intrinsics. This 
> change shows 3x improvement for Integer methods and upto 25% improvement for 
> Long. This change also implements the DivMod optimization which fuses 
> division and modulus operations if needed. The DivMod optimization shows 3x 
> improvement for Integer and ~65% improvement for Long.

Srinivas Vamsi Parasa has updated the pull request incrementally with one 
additional commit since the last revision:

  uncomment zero in integer div, mod test

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/7572/files
  - new: https://git.openjdk.java.net/jdk/pull/7572/files/bfb6c02e..3e3fc977

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=7572&range=11
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=7572&range=10-11

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7572.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7572/head:pull/7572

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