You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Xiaoming Gu (JIRA)" <ji...@apache.org> on 2008/09/01 08:13:44 UTC

[jira] Updated: (HARMONY-5901) replace integer multiplication or division with shift if one of multipliers or divisor is a power of 2

     [ https://issues.apache.org/jira/browse/HARMONY-5901?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Xiaoming Gu updated HARMONY-5901:
---------------------------------

    Attachment: H5901-V6.patch

This message is for V6 patch. In this version, I turn on the available DIV generalized strength reduction for int32 and add DIV strength reduction for int64 when the constant divisor is a power of 2. The available MUL generalized strength reduction for int32 and int64 is NOT turned on because its benefit is unstable. Following are the details of MUL & DIV strength reduction in Harmony.

	1. MUL
		a. one of multipliers is constant and a power of 2
			I. done in simplifier but not turned on
			II. done in peephole and turned on
		b. generalized strength reduction
			done in simplifier but not turned on 
			(You may turn it on by changing "simplify" to "latesimplify" in the emconf files.)
	2. DIV
		a. the divisor is an int32 constant
			done in simplifier and turned on including generalized strength reduction
		b. the divisor is an int64 constant
			done only when the divisor is a power of 2 
			(Generalized is not done because there is no support for 128-bit.)

I find in HIR2LIR, shladd HIR is NOT translated to LEA LIR. If we use LEA, we may do more study on MUL generalized strength reduction. I'm working on this now.

With this patch, there is no significant change in the five benchmarks by Stefan Krause except that the speedup of spectralnorm_long is more than 1.7 (from 14970ms to 8766ms).

> replace integer multiplication or division with shift if one of multipliers or divisor is a power of 2
> ------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5901
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5901
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Xiaoming Gu
>         Attachments: 5901.patch, H5901-V2.patch, H5901-V3.patch, H5901-V4.patch, H5901-V5.patch, H5901-V6.patch
>
>
> 1. Mulitiplication replacement
>     a. It's about integer multiplication.
>     b. One of two multipliers is a power of 2.
>     c. The power of 2 could be negative.
>     For example, 23*4 is transformed to 23<<2 and 23*(-4) is transformed to (23<<2)*(-1).
> 2. Division replacement
>     a. It's about integer division.
>     b. The divisor is a power of 2.
>     c. The power of 2 could be negative.
>     d. Because of round-up difference between division and shift right, the following equations from Aleksey are used.
>               Baseline: q = a / (1 << d);
>               Optimized: q = (a + [(1 << d) - 1] & (a >> 31)) >> d;
>     For example, 23/4 is transformed to  (23+((1<<2)-1)&(23>>31))>>2. and (-23)/(-4) is transformed to ((-23+((1<<2)-1)&(-23>>31))>>2)*(-1).
> 3. Comments for SAR and SHR swapped
>      The comments for the two similar operations were misplaced in working_vm/vm/port/src/encoder/ia32_em64t.

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