harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Rogers <rogers.em...@gmail.com>
Subject Re: generalized multiplication replacement
Date Wed, 06 Aug 2008 14:40:51 GMT
xiaoming gu wrote:
> Hi, all. Previously, Harmony Jira 5901 brought some benefits. Now I'm
> working on generalized multiplication replacement with shift and addition.
> Today I checked with gcc and found whether a multiplication is replaced or
> not in gcc mainly (not strictly) depends on the number of the replaced
> operations. There are some exceptions in gcc and I couldn't summarize the
> rule without reading the source code. So I'm planning to round it to a
> simple decision as following: if it needs >=4 shift/add operations, don't do
> replacement; Otherwise, replace it with a combination of shift/add.
> For example x*20 (20=00010100) is replaced by (x<<2+x)<<2  and x*56
> (56=00111000) is replaced by (x<<3-x)<<3 but x*29 (29=00011101) is not
> optimized by ((x<<3)-x)<<2+x.
> Any comments?
> Another question - may I read the source code of gcc since it is opensource
> in GPL? Thanks.
> Xiaoming
Hi Xiaoming,

IANAL but I guess it's not allowed to base your implementation on GCC. I 
wrote the same code for Jikes RVM [1] and I'd be happy for this CPL code 
also to be available under the ASF. This code doesn't handle the use of 
subtraction and partially computed results from earlier stages, I would 
very much like to improve it to do this. There is a tracker for Jikes 
RVM for this [2], there are also papers/programs explaining how to do 
the better approach [3][4] and some other considerations are mentioned 
in [5].

Ian Rogers

[2] http://jira.codehaus.org/browse/RVM-256
[3] http://portal.acm.org/citation.cfm?id=178249
pages 160 and 186
[5] http://www.intel.com/design/processor/manuals/248966.pdf

View raw message