RFR(M): 8170991: PPC64: Bad code for initialization of short arrays

Lindenmaier, Goetz goetz.lindenmaier at sap.com
Mon Dec 12 11:53:52 UTC 2016


Hi Martin, 

I had a look at your change.  I like you cleaned up the C1 implementation, 
moving the various cases to the macro assembler and reusing it.
I'm also fine with matching for constant array sizes.

I'm not sure whether reducing InitArrayShortSize helps.
It sure removes the simple-to-spot pattern of loading 0 too
often into registers.  This only happened if register allocation ran out
of registers and rematerialized. And as we saw, where the 0 was 
rematerialized, the register pressure was not that high, sufficient registers to 
hold 0 were available :).  This is just an artefact of register
allocation.  I would assume the processor internally handles this
efficiently.  Loading 0 into a register should be one of the cheapest 
operations altogether!
If you only look at the places where rematerialization happened, 
you miss other benefits in the places where there is no
rematerialization necessary.
So you optimize for the few cases with rematerialization, paying
the cost in the many places without rematerialization.
E.g., if 0 is used in some other places in the same code, it's there 
anyways.

So I'm not sure it helps with performance, but if you don't 
spot regressions I'm fine with the change to InitArrayShortSize, too.

Best regards,
  Goetz.




> -----Original Message-----
> From: hotspot-compiler-dev [mailto:hotspot-compiler-dev-
> bounces at openjdk.java.net] On Behalf Of Doerr, Martin
> Sent: Freitag, 9. Dezember 2016 18:01
> To: 'hotspot-compiler-dev at openjdk.java.net' <hotspot-compiler-
> dev at openjdk.java.net>; Gustavo Serra Scalet
> <gustavo.scalet at eldorado.org.br>
> Subject: RFR(M): 8170991: PPC64: Bad code for initialization of short arrays
> 
> Hello everybody,
> 
> 
> 
> the new flag "InitArrayShortSize" was set to 8 on PPC64. However, this leads to
> bad code. PPC64's C2 compiler currently does not have dedicated match rules
> to store 0.
> 
> Unfortunately, loading of the constant 0 got rematerialized many times in some
> cases consuming more registers and code space than needed.
> 
> 
> 
> An attempt to improve initialization was
> 
> 8170094: PPC64: Keep immediate value 0 cached into a register to improve
> performance
> 
> but this approach has disadvantages and we had decided against it.
> 
> 
> 
> It is possibly to implement special ClearArray nodes to improve the
> initialization of arrays only:
> 
> http://cr.openjdk.java.net/~mdoerr/8170991_PPC64_ClearArray/webrev.00/
> 
> 
> 
> Please review.
> 
> 
> 
> @Gustavo: Maybe this improves your test cases, too?
> 
> 
> 
> Best regards,
> 
> Martin
> 
> 



More information about the hotspot-compiler-dev mailing list