You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Aleksey Shipilev (JIRA)" <ji...@apache.org> on 2008/05/14 12:49:55 UTC

[jira] Created: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

[drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
----------------------------------------------------------------------------------

                 Key: HARMONY-5826
                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
             Project: Harmony
          Issue Type: Improvement
          Components: DRLVM
            Reporter: Aleksey Shipilev


Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12644494#action_12644494 ] 

Xiaoming Gu commented on HARMONY-5826:
--------------------------------------

I've checked the dump IR and find global propagation is needed if we want to get improvement as much as api magic does. I'm going to work on this.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12596732#action_12596732 ] 

Alexey Varlamov commented on HARMONY-5826:
------------------------------------------

Could this fit to peephole instead of api-magics? The unsignedMultAdd2() method does not look specific...

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoming Gu updated HARMONY-5826:
---------------------------------

    Attachment: H5826-V4.patch

This message is for V4 patch.

In this patch LIR local constant/copy propagation is added in Ia32EarlyPropagation.cpp. Previous propagation only works for operands that are defined only once in a function. With local propagation, two unnecessary MUL are both gone. If we call "early_prop, peephole" two more times in server.emconf, other unnecessary instructions (XOR and ADD) are gone too.

With some testings on crypto.rsa, I find only partial improvement got compared with the patch about api magic. I'm studying the reason now.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12659411#action_12659411 ] 

Xiaoming Gu commented on HARMONY-5826:
--------------------------------------

I do the testing about SPECjvm2008 again and find they are all passed. (Previous failures came from my messy codebase.) The current problem is some benchmarks are improved but some are degraded. The total scores are almost equal for with/without global propagation. The two most degraded benchmarks are crypto.aes and scimark.lu.small - degraded about 10%. I'm going to check whether the reason is increased compile time or not.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, H5826-V5.patch.zip, H5826-V6.zip, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoming Gu updated HARMONY-5826:
---------------------------------

    Attachment: H5826-V6.zip

This message is for V6 patch. There are four parts in it.

1. Global propagation
    A complete solution for global propagation is a kind of overkill. I decided to stay with the good enough basic solution. It's in Ia32GlobalPropagation.cpp. Please put this file in $HARMONY\working_vm\vm\jitrino\src\codegenerator\ia32.

2. 64-bit multiplication lower
    In Ia32I8Lowerer.cpp, a 64-bit mulitiplication used to be lowered serveral 32-bit operations which are put into 3 basic blocks. Now it's changed that all generated 32-bit operations are in a single basic block. This change is for peephole optimization on ADD.

3. Peephole optimization
    a. MUL - Previously only instruction with IMUL is optimized. Now the optimization for MUL is added.
    b. ADD - Previously no peephole optimization for ADD. Now the optimization for ADD is added.
    c. Local propagation - Some MUL and ADD are optimized to MOV in peephole optimization. The integrated local propagation could utilize these on-the-fly opportunities.

4. Emconf files
    Early_prop is replaced by global_prop in all server related emconf files.


Currently Harmony with this patch could pass most benchmarks in SPECjvm2008. Some fails but I guess it is not the problem of this patch. crypto.rsa is improved more than 40% (from 208.98 to 305.56) and the optimized code of unsignedMultAddAdd() is as same as api magic did before. 

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, H5826-V5.patch.zip, H5826-V6.zip, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoming Gu updated HARMONY-5826:
---------------------------------

    Attachment: H5826-V5.patch.zip

This message is for V5 patch, which is just alpha release of global propagation. In the patch, there are two files - one for new global propagation and one for other changes. Please put the new file to $HARMONY\working_vm\vm\jitrino\src\codegenerator\ia32.

With global propagation two unnecessay MUL in java/math/Division.unsignedMultAddAdd() are deleted. And we get most part of expected improvement in crypto.rsa - from 195.01 to 237.22 (ideal is 247.65 in the way of api-magic). We need to do more in peephole to delete left unnecessary instructions to get whole expected improvement.

The current global propagation doesn't catch all optimizing opportunities. I'm going to augment it to a complete version.



> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, H5826-V5.patch.zip, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12676842#action_12676842 ] 

Xiaoming Gu commented on HARMONY-5826:
--------------------------------------

Good job, Chunrong. Thanks.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>            Assignee: Chunrong Lai
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, H5826-V5.patch.zip, H5826-V6.zip, H5826-V7.zip, H5826-V8.zip, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Simon.Zhou (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12710086#action_12710086 ] 

Simon.Zhou commented on HARMONY-5826:
-------------------------------------

Xiaoming, I am afraid this patch breaks the functionality of gc.generate_barrier option. When I am using -XX:gc.generate_barrier=true, VM crashes when it startup (in vm_init2()).
I tried to trace the issue, then I find the error came from
java.net.URI$Helper.parseURI (URI.java: 240)
the assignment of  scheme=temp.substring(0, index); does not work, i.e. scheme is still NULL after executing this line. 
This is all I got, but I am not sure what happened here exactly. would you like to check this issue when you are convenient. Thanks!

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>            Assignee: Chunrong Lai
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, H5826-V5.patch.zip, H5826-V6.zip, H5826-V7.zip, H5826-V8.zip, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoming Gu updated HARMONY-5826:
---------------------------------

    Attachment: H5826-V8.zip

This message is for V8 patch. Some changes are made for better comments in Ia32GlobalPropagation.cpp.

I finished some preliminary testings such as cunit.test, jvmti.test, kernel.test, reg.test and smoke.test on Windows32 and Linux32 and all of them are successful.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, H5826-V5.patch.zip, H5826-V6.zip, H5826-V7.zip, H5826-V8.zip, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoming Gu updated HARMONY-5826:
---------------------------------

    Attachment: H5826-V3.patch

This message is for V3 patch.

In this patch, heephole optimization for MUL is done. Previously, there is only optimization for IMUL. Now one of the two unnecessary 32-bit MUL is eliminated and performance is improved about 11%.

Following work is mainly on constant/copy propagation in LIR. Currently the available "early_prop" does NOT have the satisfying strength.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, H5826-V3.patch, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12638224#action_12638224 ] 

Xiaoming Gu commented on HARMONY-5826:
--------------------------------------

With some testing, I couldn't get any improvement on crypto.rsa in r699565 (actually performance is degraded a little with this patch). It seems current JIT generates better code in common way than in magic way.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Mikhail Fursov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12596735#action_12596735 ] 

Mikhail Fursov commented on HARMONY-5826:
-----------------------------------------

It looks like that HLO simplifier must do the same job.
 
Aleksey, could you show us a HIR part of this method right before the 'hir2lir' pass?

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12638719#action_12638719 ] 

Xiaoming Gu commented on HARMONY-5826:
--------------------------------------

I find the benefits of this patch come from changing a 64-bit MUL (3 32-bit MUL and 2 32-bit ADD) to a 32-bit MUL. At present, the optimization is done as a magic replacement, which is not a common way to generate code.

Assume A and B are both 64-bit operands and we are doing A*B. In 32-bit machine, the MUL operation is usually translated to (High 32-bit of A)*(Low 32-bit of b)+(Low 32-bit of A)*(High 32-bit of B)+(Low 32-bit of A)*(Low 32-bit of A). But when we know High 32-bit of A and B are both 0, only (Low 32-bit of A)*(Low 32-bit of A) needed.

Following are the HIR and LIR for result = (a & ffffffffL) * (b & ffffffffL) + (c & ffffffffL) + (d & ffffffffL) without this patch. We can do the optimization in HIR simplifier or LIR peephole. I'm not sure whether changing int64 operation to int32 operation will bring overhead for 64-bit machine. I think maybe peephole is a better place. I find there is no peephole optimization for XOR. If JIT could find out the result of XOR is 0, then propagates the 0 to MUL and related MUL is eliminated. The left problem is whether there is sufficient data-flow analysis in LIR to do the propagation and elimination.
=====HIR=====
  I42:ldci8     #4294967295 -) t38:int64
  I43:and       t37, t38 -) t39:int64
  I44:convi8  g23 -) t40:int64
  I45:and       t40, t38 -) t41:int64
  I46:mul   t39, t41 -) t42:int64
=====LIR=====
	238B02A6 I329: MOV s286[v208(ESP)+t285(-100)]:I_32,v19(EAX):I_32 
	238B02AA I328: MOV t291[v208(ESP)+t290(-104)]:I_32,v19(EAX):I_32 
	238B02AE I327: (ID:s8(EFLGS):U_32) =XOR t206(EDX):I_32,t206(EDX):I_32 
	238B02B0 I326: MOV s292(EAX):I_32,s286[v208(ESP)+t285(-100)]:I_32 
	238B02B4 I70: (ID:s8(EFLGS):U_32) =MUL s139(EDX):I_32,s292(EAX):I_32,t206(EDX):I_32 
	238B02B6 I325: MOV s140(EBX):I_32,s292(EAX):I_32 
	238B02B8 I324: (ID:s8(EFLGS):U_32) =XOR s292(EAX):I_32,s292(EAX):I_32 
	238B02BA I323: MOV t289(EDI):I_32,v217[v208(ESP)+t216(-24)]:I_32 
	238B02BE I73: (ID:s8(EFLGS):U_32) =MUL s139(EDX):I_32,s292(EAX):I_32,t289(EDI):I_32 
	238B02C0 I74: (ID:s8(EFLGS):U_32) =ADD s140(EBX):I_32,s292(EAX):I_32 
	238B02C2 I322: MOV v19(EAX):I_32,t291[v208(ESP)+t290(-104)]:I_32 
	DEADBEEF I75: (AD:s293(EAX):I_32) =CopyPseudoInst/MOV (AU:v19(EAX):I_32) 
	238B02C6 I76: (ID:s8(EFLGS):U_32) =MUL s139(EDX):I_32,s293(EAX):I_32,t289(EDI):I_32 
	238B02C8 I321: MOV s286[v208(ESP)+t285(-100)]:I_32,s293(EAX):I_32 
	238B02CC I77: (ID:s8(EFLGS):U_32) =ADD s139(EDX):I_32,s140(EBX):I_32 

Any comments? Thanks.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Chunrong Lai (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chunrong Lai reassigned HARMONY-5826:
-------------------------------------

    Assignee: Chunrong Lai

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>            Assignee: Chunrong Lai
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, H5826-V5.patch.zip, H5826-V6.zip, H5826-V7.zip, H5826-V8.zip, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Aleksey Shipilev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12596749#action_12596749 ] 

Aleksey Shipilev commented on HARMONY-5826:
-------------------------------------------

The thing here is: method performs fast multiplication of "unsigned int"s. 

------ "C": -------
unsigned int a, b, c, d;
long result;

result = a * b + c + d;

------ "Java": -------
int a, b, c, d;
result = (a & ffffffffL) * (b & ffffffffL)  + (c & ffffffffL) + (d & ffffffffL) 

------ ASM: -------
mov eax, a
mul eax, eax, b
add eax, c
adc edx, 0
add eax, d
adc edx, 0
mov resLo, eax
mov resHi, edx

That is, we need to perform zero expansion if doing such thing in Java, while we can avoid that in native code.
Can HLO simplifier or peephole detect that result is long and eliminate such "zero expansion"?


> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12652269#action_12652269 ] 

Xiaoming Gu commented on HARMONY-5826:
--------------------------------------

The patch for H6027 is included in the above V5 patch.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, H5826-V5.patch.zip, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12638242#action_12638242 ] 

Xiaoming Gu commented on HARMONY-5826:
--------------------------------------

Sorry for the last message. I find there is no effect with this patch when running crypto.rsa. I'll study more.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12639403#action_12639403 ] 

Xiaoming Gu commented on HARMONY-5826:
--------------------------------------

With some work, I find this optimization has to be done in LIR after i8 operation lowered to i4 operation. If we do it in HIR symplifier, MUL on int32 only generates IMUL finally and the higher 32 bits of (Low 32-bit of A)*(Low 32-bit of A) are lost. I'm going to try peephole in LIR.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoming Gu updated HARMONY-5826:
---------------------------------

    Attachment: H5826-V2.patch

This message is for V2 patch.

Some changes are made following Aleksey's suggestion. Now the improvement is about 30% (from 192.01 to 249.76) on my 4-core desktop.

I'm going to look into the patch to check whether it could be implemented in peephole or some other common pass.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Chunrong Lai (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12676693#action_12676693 ] 

Chunrong Lai commented on HARMONY-5826:
---------------------------------------


 Committed in r747844. Xiaoming, please verify.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>            Assignee: Chunrong Lai
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, H5826-V5.patch.zip, H5826-V6.zip, H5826-V7.zip, H5826-V8.zip, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Aleksey Shipilev (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aleksey Shipilev updated HARMONY-5826:
--------------------------------------

    Attachment: vm-jit-math-unsignedMultAdd2-magic-rc1.patch

vm-jit-math-unsignedMultAdd2-magic-rc1.patch
Proposed patch.

Implements magic for required method.

Gives +35% boost on SPECjvm2008:crypto.rsa on 8-core Clovertown.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Aleksey Shipilev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12638249#action_12638249 ] 

Aleksey Shipilev commented on HARMONY-5826:
-------------------------------------------

Xiaoming, please update the patch: JIT looks for unsignedMultAdd2, where in current classlib version the method is unsignedMultAddAdd. So, no substitution is occuring. Can you fix the patch and run crypto:rsa once again?

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5826) [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2

Posted by "Xiaoming Gu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5826?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoming Gu updated HARMONY-5826:
---------------------------------

    Attachment: H5826-V7.zip

This message is for V7. 

In this version, the main change is that global_prop works with early_prop in server, server_aggressive and server_static modes. I spent some days to study the degradations in some benchmarks of SPECjvm2008 when using V6. Finally I found the reason is the propagation on MEM operands. After trying several ways, I thought the best way is to reuse the code in early_prop. So the two optimizations about propagations work together now and we don't miss any opportunity caught before.

> [drlvm][jit][opt][performance] Magic for java.math.Multiplication.unsignedMultAdd2
> ----------------------------------------------------------------------------------
>
>                 Key: HARMONY-5826
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5826
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Aleksey Shipilev
>         Attachments: H5826-V2.patch, H5826-V3.patch, H5826-V4.patch, H5826-V5.patch.zip, H5826-V6.zip, H5826-V7.zip, vm-jit-math-unsignedMultAdd2-magic-rc1.patch
>
>
> Implementation of magic for java.math.Multiplication.unsignedMultAdd2, extracted in HARMONY-5825.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.