# HG changeset patch # User roland # Date 1461002247 -10800 # Node ID f8383064eaa286347eb491290a9c660a6ffdae1b # Parent 808cbf1958ce8dcd3b33a44c2967d29b0e4c2a6a 8154135: Loop alignment may be added inside the loop body Reviewed-by: kvn, vlivanov diff -r 808cbf1958ce -r f8383064eaa2 hotspot/src/share/vm/opto/block.cpp --- a/hotspot/src/share/vm/opto/block.cpp Mon Apr 18 11:22:51 2016 +0200 +++ b/hotspot/src/share/vm/opto/block.cpp Mon Apr 18 20:57:27 2016 +0300 @@ -73,7 +73,7 @@ } #endif -uint Block::code_alignment() { +uint Block::code_alignment() const { // Check for Root block if (_pre_order == 0) return CodeEntryAlignment; // Check for Start block @@ -1727,8 +1727,14 @@ first_block()->set_loop_alignment(targ_block); } else { - // Backbranch into the middle of a trace - targ_block->set_loop_alignment(targ_block); + // That loop may already have a loop top (we're reaching it again + // through the backedge of an outer loop) + Block* b = prev(targ_block); + bool has_top = targ_block->head()->is_Loop() && b->has_loop_alignment() && !b->head()->is_Loop(); + if (!has_top) { + // Backbranch into the middle of a trace + targ_block->set_loop_alignment(targ_block); + } } return loop_rotated; diff -r 808cbf1958ce -r f8383064eaa2 hotspot/src/share/vm/opto/block.hpp --- a/hotspot/src/share/vm/opto/block.hpp Mon Apr 18 11:22:51 2016 +0200 +++ b/hotspot/src/share/vm/opto/block.hpp Mon Apr 18 20:57:27 2016 +0300 @@ -197,7 +197,7 @@ // Report the alignment required by this block. Must be a power of 2. // The previous block will insert nops to get this alignment. - uint code_alignment(); + uint code_alignment() const; uint compute_loop_alignment(); // BLOCK_FREQUENCY is a sentinel to mark uses of constant block frequencies. diff -r 808cbf1958ce -r f8383064eaa2 hotspot/src/share/vm/opto/c2_globals.hpp --- a/hotspot/src/share/vm/opto/c2_globals.hpp Mon Apr 18 11:22:51 2016 +0200 +++ b/hotspot/src/share/vm/opto/c2_globals.hpp Mon Apr 18 20:57:27 2016 +0300 @@ -587,7 +587,7 @@ range(0, 100) \ \ product(bool, BlockLayoutRotateLoops, true, \ - "Allow back branches to be fall throughs in the block layour") \ + "Allow back branches to be fall throughs in the block layout") \ \ develop(bool, InlineReflectionGetCallerClass, true, \ "inline sun.reflect.Reflection.getCallerClass(), known to be " \