Skip to content

Commit 805f1de

Browse files
Saranya NatarajanDaniel Lundén
authored andcommitted
8342941: IGV: Add various new graph dumps during loop opts
Reviewed-by: chagedorn, dlunden
1 parent b85440d commit 805f1de

File tree

7 files changed

+33
-7
lines changed

7 files changed

+33
-7
lines changed

src/hotspot/share/opto/loopTransform.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ bool IdealLoopTree::policy_maximally_unroll(PhaseIdealLoop* phase) const {
862862

863863
uint trip_count = cl->trip_count();
864864
// Note, max_juint is used to indicate unknown trip count.
865-
assert(trip_count > 1, "one iteration loop should be optimized out already");
865+
assert(trip_count > 1, "one-iteration loop should be optimized out already");
866866
assert(trip_count < max_juint, "exact trip_count should be less than max_juint.");
867867

868868
// If nodes are depleted, some transform has miscalculated its needs.
@@ -1399,6 +1399,7 @@ void PhaseIdealLoop::insert_pre_post_loops(IdealLoopTree *loop, Node_List &old_n
13991399
CountedLoopNode *post_head = nullptr;
14001400
Node* post_incr = incr;
14011401
Node* main_exit = insert_post_loop(loop, old_new, main_head, main_end, post_incr, limit, post_head);
1402+
C->print_method(PHASE_AFTER_POST_LOOP, 4, post_head);
14021403

14031404
//------------------------------
14041405
// Step B: Create Pre-Loop.
@@ -1613,8 +1614,10 @@ void PhaseIdealLoop::insert_vector_post_loop(IdealLoopTree *loop, Node_List &old
16131614
Node *limit = main_end->limit();
16141615

16151616
// In this case we throw away the result as we are not using it to connect anything else.
1617+
C->print_method(PHASE_BEFORE_POST_LOOP, 4, main_head);
16161618
CountedLoopNode *post_head = nullptr;
16171619
insert_post_loop(loop, old_new, main_head, main_end, incr, limit, post_head);
1620+
C->print_method(PHASE_AFTER_POST_LOOP, 4, post_head);
16181621

16191622
// It's difficult to be precise about the trip-counts
16201623
// for post loops. They are usually very short,
@@ -3077,6 +3080,7 @@ bool IdealLoopTree::do_remove_empty_loop(PhaseIdealLoop *phase) {
30773080
return false;
30783081
}
30793082
}
3083+
phase->C->print_method(PHASE_BEFORE_REMOVE_EMPTY_LOOP, 4, cl);
30803084
if (cl->is_pre_loop()) {
30813085
// If the loop we are removing is a pre-loop then the main and post loop
30823086
// can be removed as well.
@@ -3179,6 +3183,7 @@ bool IdealLoopTree::do_remove_empty_loop(PhaseIdealLoop *phase) {
31793183
phase->_igvn.replace_input_of(cl->loopexit(), CountedLoopEndNode::TestValue, zero);
31803184

31813185
phase->C->set_major_progress();
3186+
phase->C->print_method(PHASE_AFTER_REMOVE_EMPTY_LOOP, 4, final_iv);
31823187
return true;
31833188
}
31843189

@@ -3314,7 +3319,7 @@ void IdealLoopTree::collect_loop_core_nodes(PhaseIdealLoop* phase, Unique_Node_L
33143319
}
33153320

33163321
//------------------------------do_one_iteration_loop--------------------------
3317-
// Convert one iteration loop into normal code.
3322+
// Convert one-iteration loop into normal code.
33183323
bool IdealLoopTree::do_one_iteration_loop(PhaseIdealLoop *phase) {
33193324
if (!_head->as_Loop()->is_valid_counted_loop(T_INT)) {
33203325
return false; // Only for counted loop
@@ -3331,6 +3336,7 @@ bool IdealLoopTree::do_one_iteration_loop(PhaseIdealLoop *phase) {
33313336
}
33323337
#endif
33333338

3339+
phase->C->print_method(PHASE_BEFORE_ONE_ITERATION_LOOP, 4, cl);
33343340
Node *init_n = cl->init_trip();
33353341
// Loop boundaries should be constant since trip count is exact.
33363342
assert((cl->stride_con() > 0 && init_n->get_int() + cl->stride_con() >= cl->limit()->get_int()) ||
@@ -3340,6 +3346,7 @@ bool IdealLoopTree::do_one_iteration_loop(PhaseIdealLoop *phase) {
33403346
// and all loop-invariant uses of the exit values will be correct.
33413347
phase->_igvn.replace_node(cl->phi(), cl->init_trip());
33423348
phase->C->set_major_progress();
3349+
phase->C->print_method(PHASE_AFTER_ONE_ITERATION_LOOP, 4, init_n);
33433350
return true;
33443351
}
33453352

@@ -3354,7 +3361,7 @@ bool IdealLoopTree::iteration_split_impl(PhaseIdealLoop *phase, Node_List &old_n
33543361
// Compute loop trip count if possible.
33553362
compute_trip_count(phase);
33563363

3357-
// Convert one iteration loop into normal code.
3364+
// Convert one-iteration loop into normal code.
33583365
if (do_one_iteration_loop(phase)) {
33593366
return true;
33603367
}

src/hotspot/share/opto/loopnode.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ class IdealLoopTree : public ResourceObj {
742742
// Micro-benchmark spamming. Remove empty loops.
743743
bool do_remove_empty_loop( PhaseIdealLoop *phase );
744744

745-
// Convert one iteration loop into normal code.
745+
// Convert one-iteration loop into normal code.
746746
bool do_one_iteration_loop( PhaseIdealLoop *phase );
747747

748748
// Return TRUE or FALSE if the loop should be peeled or not. Peel if we can

src/hotspot/share/opto/loopopts.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4338,6 +4338,7 @@ bool PhaseIdealLoop::duplicate_loop_backedge(IdealLoopTree *loop, Node_List &old
43384338
}
43394339
}
43404340
}
4341+
C->print_method(PHASE_BEFORE_DUPLICATE_LOOP_BACKEDGE, 4, head);
43414342

43424343
// Collect data nodes that need to be clones as well
43434344
int dd = dom_depth(head);
@@ -4428,6 +4429,8 @@ bool PhaseIdealLoop::duplicate_loop_backedge(IdealLoopTree *loop, Node_List &old
44284429

44294430
C->set_major_progress();
44304431

4432+
C->print_method(PHASE_AFTER_DUPLICATE_LOOP_BACKEDGE, 4, outer_head);
4433+
44314434
return true;
44324435
}
44334436

src/hotspot/share/opto/phasetype.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@
7575
flags(ITER_GVN_AFTER_ELIMINATION, "Iter GVN after Eliminating Allocations and Locks") \
7676
flags(BEFORE_PRE_MAIN_POST, "Before Pre/Main/Post Loops") \
7777
flags(AFTER_PRE_MAIN_POST, "After Pre/Main/Post Loops") \
78+
flags(BEFORE_POST_LOOP, "Before Post Loop") \
79+
flags(AFTER_POST_LOOP, "After Post Loop") \
80+
flags(BEFORE_REMOVE_EMPTY_LOOP, "Before Remove Empty Loop") \
81+
flags(AFTER_REMOVE_EMPTY_LOOP, "After Remove Empty Loop") \
82+
flags(BEFORE_ONE_ITERATION_LOOP, "Before Replace One-Iteration Loop") \
83+
flags(AFTER_ONE_ITERATION_LOOP, "After Replace One-Iteration Loop") \
84+
flags(BEFORE_DUPLICATE_LOOP_BACKEDGE, "Before Duplicate Loop Backedge") \
85+
flags(AFTER_DUPLICATE_LOOP_BACKEDGE, "After Duplicate Loop Backedge") \
7886
flags(BEFORE_LOOP_UNROLLING, "Before Loop Unrolling") \
7987
flags(AFTER_LOOP_UNROLLING, "After Loop Unrolling") \
8088
flags(PHASEIDEALLOOP1, "PhaseIdealLoop 1") \

test/hotspot/jtreg/compiler/lib/ir_framework/CompilePhase.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ public enum CompilePhase {
8686
ITER_GVN_AFTER_ELIMINATION( "Iter GVN after Eliminating Allocations and Locks"),
8787
BEFORE_PRE_MAIN_POST( "Before Pre/Main/Post Loops"),
8888
AFTER_PRE_MAIN_POST( "After Pre/Main/Post Loops"),
89+
BEFORE_POST_LOOP( "Before Post Loop"),
90+
AFTER_POST_LOOP( "After Post Loop"),
91+
BEFORE_REMOVE_EMPTY_LOOP( "Before Remove Empty Loop"),
92+
AFTER_REMOVE_EMPTY_LOOP( "After Remove Empty Loop"),
93+
BEFORE_ONE_ITERATION_LOOP( "Before Replacing One-Iteration Loop"),
94+
AFTER_ONE_ITERATION_LOOP( "After Replacing One-Iteration Loop"),
95+
BEFORE_DUPLICATE_LOOP_BACKEDGE( "Before Duplicate Loop Backedge"),
96+
AFTER_DUPLICATE_LOOP_BACKEDGE( "After Duplicate Loop Backedge"),
8997
PHASEIDEALLOOP1( "PhaseIdealLoop 1"),
9098
PHASEIDEALLOOP2( "PhaseIdealLoop 2"),
9199
PHASEIDEALLOOP3( "PhaseIdealLoop 3"),

test/hotspot/jtreg/compiler/predicates/assertion/TestTemplateWithoutOpaqueLoopNodes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
/*
2525
* @test id=Xcomp
2626
* @bug 8333252
27-
* @summary Test that no Template Assertion Predicate is created in Loop Prediction for one iteration loop.
27+
* @summary Test that no Template Assertion Predicate is created in Loop Prediction for one-iteration loop.
2828
* @run main/othervm -Xcomp -XX:CompileCommand=compileonly,*TestTemplateWithoutOpaqueLoopNodes::test
2929
* compiler.predicates.assertion.TestTemplateWithoutOpaqueLoopNodes
3030
*/
3131

3232
/*
3333
* @test id=Xbatch
3434
* @bug 8333252
35-
* @summary Test that no Template Assertion Predicate is created in Loop Prediction for one iteration loop.
35+
* @summary Test that no Template Assertion Predicate is created in Loop Prediction for one-iteration loop.
3636
* @run main/othervm -Xbatch -XX:CompileCommand=compileonly,*TestTemplateWithoutOpaqueLoopNodes::test
3737
* compiler.predicates.assertion.TestTemplateWithoutOpaqueLoopNodes
3838
*/

test/hotspot/jtreg/compiler/splitif/TestSplitDivisionThroughPhi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static void testPushModLThruPhiForOuterLongLoop() {
140140
// the iv phi in one pass of Split If.
141141
static void testPushDivIThruPhiInChain() {
142142
for (int i = 10; i > 1; i -= 2) {
143-
// Empty one iteration loop which is only removed after split if in first loop opts phase. This prevents
143+
// Empty one-iteration loop which is only removed after split if in first loop opts phase. This prevents
144144
// that the Mul node is already split through the iv phi while the Div node cannot be split yet due to
145145
// the zero divisor check which can only be removed in the IGVN after the first loop opts pass.
146146
for (int j = 0; j < 1; j++) {

0 commit comments

Comments
 (0)