RFR(S): 8136820 Generate better code for some Unsafe addressing patterns
Vladimir Kozlov
vladimir.kozlov at oracle.com
Tue Sep 22 11:07:36 UTC 2015
Hi Roland,
It would be nice if you describe your changes (RFE also has nothing).
Especially changes in matcher.cpp. From what I can understand changes
are good but please explain what you did.
Thanks,
Vladimir
On 9/21/15 6:00 PM, Roland Westrelin wrote:
> http://cr.openjdk.java.net/~roland/8136820/webrev.00/
>
> The main loop in:
>
> static int[] array;
> static long base;
> static int test1() {
> int res = 0;
> for (int i = 0; i < 100; i++) {
> long address = (((long) i) << 2) + base;
> res += UNSAFE.getInt(array, address);
> }
> return res;
> }
>
> is compiled as:
>
> 0b0 B2: # B2 B3 <- B1 B2 Loop: B2-B2 inner Freq: 101.492
> 0b0 movslq R9, R10 # i2l
> 0b3 salq R9, #2
> 0b7 addq R9, [R11 + #112 (8-bit)] # long
> 0bb addl RAX, [R8 + R9] # int
> 0bf incl R10 # int
> 0c2 cmpl R10, #100
> 0c6 jl,s B2 # loop end P=0.990147 C=6732.000000
>
> but could be compiled as:
>
> 0b2 B2: # B2 B3 <- B1 B2 Loop: B2-B2 inner Freq: 101.492
> 0b2 addl RAX, [R8 + pos R10 << #2] # int
> 0b6 incl R10 # int
> 0b9 cmpl R10, #100
> 0bd jl,s B2 # loop end P=0.990147 C=6732.000000
>
> base and array are loop invariant so array + base can be computed before the loop.
>
> Roland.
>
More information about the hotspot-compiler-dev
mailing list