8035283: Second phase of branch shortening doesn't account for loop alignment

Fri, 28 Feb 2014 02:43:16 -0800

author
poonam
date
Fri, 28 Feb 2014 02:43:16 -0800
changeset 6592
c96a3381e55e
parent 6591
559d297c72e9
child 6593
9b289963cb9a

8035283: Second phase of branch shortening doesn't account for loop alignment
Summary: added missing check for loop padding case.
Reviewed-by: kvn, jrose

src/share/vm/opto/output.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/opto/output.cpp	Thu Mar 06 13:31:19 2014 -0800
     1.2 +++ b/src/share/vm/opto/output.cpp	Fri Feb 28 02:43:16 2014 -0800
     1.3 @@ -344,6 +344,11 @@
     1.4    uint*      jmp_offset = NEW_RESOURCE_ARRAY(uint,nblocks);
     1.5    uint*      jmp_size   = NEW_RESOURCE_ARRAY(uint,nblocks);
     1.6    int*       jmp_nidx   = NEW_RESOURCE_ARRAY(int ,nblocks);
     1.7 +
     1.8 +  // Collect worst case block paddings
     1.9 +  int* block_worst_case_pad = NEW_RESOURCE_ARRAY(int, nblocks);
    1.10 +  memset(block_worst_case_pad, 0, nblocks * sizeof(int));
    1.11 +
    1.12    DEBUG_ONLY( uint *jmp_target = NEW_RESOURCE_ARRAY(uint,nblocks); )
    1.13    DEBUG_ONLY( uint *jmp_rule = NEW_RESOURCE_ARRAY(uint,nblocks); )
    1.14  
    1.15 @@ -460,6 +465,7 @@
    1.16            last_avoid_back_to_back_adr += max_loop_pad;
    1.17          }
    1.18          blk_size += max_loop_pad;
    1.19 +        block_worst_case_pad[i + 1] = max_loop_pad;
    1.20        }
    1.21      }
    1.22  
    1.23 @@ -499,9 +505,16 @@
    1.24          if (bnum > i) { // adjust following block's offset
    1.25            offset -= adjust_block_start;
    1.26          }
    1.27 +
    1.28 +        // This block can be a loop header, account for the padding
    1.29 +        // in the previous block.
    1.30 +        int block_padding = block_worst_case_pad[i];
    1.31 +        assert(i == 0 || block_padding == 0 || br_offs >= block_padding, "Should have at least a padding on top");
    1.32          // In the following code a nop could be inserted before
    1.33          // the branch which will increase the backward distance.
    1.34 -        bool needs_padding = ((uint)br_offs == last_may_be_short_branch_adr);
    1.35 +        bool needs_padding = ((uint)(br_offs - block_padding) == last_may_be_short_branch_adr);
    1.36 +        assert(!needs_padding || jmp_offset[i] == 0, "padding only branches at the beginning of block");
    1.37 +
    1.38          if (needs_padding && offset <= 0)
    1.39            offset -= nop_size;
    1.40  

mercurial