Removing redundant addis's

Lindenmaier, Goetz goetz.lindenmaier at sap.com
Mon Oct 10 09:07:51 UTC 2016


Hi Bruno, 

the emitters in the assembler_<platform>.* files are meant to be pure emitters
without optimizations.  Callers can rely that the instruction is emitted, which 
might be important for effects like code alignment or instruction scheduling.
So you should not change them.

If this is not an accidential occurance you should identify the place where this is
emitted and call mr_if_needed() instead, or issue a nop.

Best regards,
  Goetz.


> -----Original Message-----
> From: ppc-aix-port-dev [mailto:ppc-aix-port-dev-
> bounces at openjdk.java.net] On Behalf Of Bruno Alexandre Rosa
> Sent: Freitag, 7. Oktober 2016 22:53
> To: ppc-aix-port-dev at openjdk.java.net
> Subject: Removing redundant addis's
> 
> Hello, everyone,
> 
> 
> 
> I've been taking a look at some performance optmization opportunities in
> the
> 
> ppc64-specific HotSpot code and stumbled upon some oddities in the jitted
> code
> 
> like:
> 
> 
> 
> addis r20, r20, 0
> 
> 
> 
> I went ahead and modified the Assembler not to emit an addis when the
> operands
> 
> are the same and the offset is 0.
> 
> 
> 
> I tried adding similar conditions on every "__ addis" call on ppc.ad, but
> 
> thought this kind of solution is inelegant and harder to maintain. Then I went
> 
> for a simpler solution.
> 
> 
> 
> Here is the diff:
> 
> 
> 
> diff -r b89f80ea707c src/cpu/ppc/vm/assembler_ppc.inline.hpp
> 
> --- a/src/cpu/ppc/vm/assembler_ppc.inline.hpp   Fri Oct 07 16:58:57 2016 -
> 0300
> 
> +++ b/src/cpu/ppc/vm/assembler_ppc.inline.hpp   Fri Oct 07 19:36:17 2016 -
> 0300
> 
> @@ -82,7 +82,7 @@
> 
> 
> 
> // PPC 1, section 3.3.8, Fixed-Point Arithmetic Instructions
> 
> inline void Assembler::addi(   Register d, Register a, int si16)   { assert(a != R0,
> "r0 not allowed"); addi_r0ok( d, a, si16); }
> 
> -inline void Assembler::addis(  Register d, Register a, int si16)   { assert(a !=
> R0, "r0 not allowed"); addis_r0ok(d, a, si16); }
> 
> +inline void Assembler::addis(  Register d, Register a, int si16)   { assert(a !=
> R0, "r0 not allowed"); if (d != a || si16 != 0) addis_r0ok(d, a, si16); }
> 
> inline void Assembler::addi_r0ok(Register d,Register a,int si16)   {
> emit_int32(ADDI_OPCODE   | rt(d) | ra(a) | simm(si16, 16)); }
> 
> inline void Assembler::addis_r0ok(Register d,Register a,int si16)  {
> emit_int32(ADDIS_OPCODE  | rt(d) | ra(a) | simm(si16, 16)); }
> 
> inline void Assembler::addic_( Register d, Register a, int si16)   {
> emit_int32(ADDIC__OPCODE | rt(d) | ra(a) | simm(si16, 16)); }
> 
>  However, I'm concerned this modification might be too intrusive. So I came
> here
> 
> to ask opinions on that.
> 
>  Regards,
> 
> Bruno Rosa



More information about the ppc-aix-port-dev mailing list