Bug in LIRGenerator::generate_address on sparc?

Tom Rodriguez Thomas.Rodriguez at Sun.COM
Mon Nov 26 16:59:06 PST 2007


That does indeed look wrong.  I don't think your changes to reduce 
register wastage are a good idea though.  Keep in mind that these are 
virtual registers and should generally be created every time a new value 
is defined.  They should never be reused for multiple defs otherwise you 
may be killing a value which is used in some later part of the code. 
The allocator should be a reasonable job of reusing registers for you 
particularly within a basic block.  Are you see problems caused by these 
extra virtual registers?

Anyway, that path doesn't appear to currently be used but I think the 
right fix is simply this:

** /tmp/geta2158       Mon Nov 26 16:53:49 2007
--- c1_LIRGenerator_sparc.cpp   Mon Nov 26 16:49:48 2007
***************
*** 151,157 ****
       if (disp != 0) {
         LIR_Opr tmp = new_register(T_INT);
         if (Assembler::is_simm13(disp)) {
!         __ add(tmp, LIR_OprFact::intConst(disp), tmp);
           index = tmp;
         } else {
           __ move(LIR_OprFact::intConst(disp), tmp);
--- 151,157 ----
       if (disp != 0) {
         LIR_Opr tmp = new_register(T_INT);
         if (Assembler::is_simm13(disp)) {
!         __ add(index, LIR_OprFact::intConst(disp), tmp);
           index = tmp;
         } else {
           __ move(LIR_OprFact::intConst(disp), tmp);

I'll file a bug for this.

tom


Gary Benson wrote:
> Hi all,
> 
> I'm currently working on porting c1 to PPC.  I copied the sparc
> implementation of LIRGenerator::generate_address, and at first
> I thought it was wasting a register when called with a register
> index, nonzero shift and nonzero simm13 displacement, but as I
> looked at it it seems broken.  It does this:
> 
>   LIR_Opr tmp = new_register(T_INT);
>   __ add(tmp, LIR_OprFact::intConst(disp), tmp);
> 
> which as far as I can see is starting with a random value in tmp.
> I guess this particular case doesn't get used, but here is my
> (untested) fix for both the bug and the register wastage.
> 
> Cheers,
> Gary
> 



More information about the hotspot-compiler-dev mailing list