Skip to content

Commit 1ed9c76

Browse files
committed
8309204: Obsolete DoReserveCopyInSuperWord
Reviewed-by: kvn, thartmann
1 parent 3630af2 commit 1ed9c76

File tree

11 files changed

+66
-312
lines changed

11 files changed

+66
-312
lines changed

src/hotspot/share/opto/c2_globals.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,6 @@
341341
product(bool, UseCMoveUnconditionally, false, \
342342
"Use CMove (scalar and vector) ignoring profitability test.") \
343343
\
344-
product(bool, DoReserveCopyInSuperWord, true, \
345-
"Create reserve copy of graph in SuperWord.") \
346-
\
347344
notproduct(bool, TraceSuperWord, false, \
348345
"Trace superword transforms") \
349346
\

src/hotspot/share/opto/c2compiler.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ const char* C2Compiler::retry_no_iterative_escape_analysis() {
5555
const char* C2Compiler::retry_no_reduce_allocation_merges() {
5656
return "retry without reducing allocation merges";
5757
}
58+
const char* C2Compiler::retry_no_superword() {
59+
return "retry without SuperWord";
60+
}
5861

5962
void compiler_stubs_init(bool in_compiler_thread);
6063

@@ -112,10 +115,18 @@ void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, boo
112115
bool do_reduce_allocation_merges = ReduceAllocationMerges && EliminateAllocations;
113116
bool eliminate_boxing = EliminateAutoBox;
114117
bool do_locks_coarsening = EliminateLocks;
118+
bool do_superword = UseSuperWord;
115119

116120
while (!env->failing()) {
117121
// Attempt to compile while subsuming loads into machine instructions.
118-
Options options(subsume_loads, do_escape_analysis, do_iterative_escape_analysis, do_reduce_allocation_merges, eliminate_boxing, do_locks_coarsening, install_code);
122+
Options options(subsume_loads,
123+
do_escape_analysis,
124+
do_iterative_escape_analysis,
125+
do_reduce_allocation_merges,
126+
eliminate_boxing,
127+
do_locks_coarsening,
128+
do_superword,
129+
install_code);
119130
Compile C(env, target, entry_bci, options, directive);
120131

121132
// Check result and retry if appropriate.
@@ -150,6 +161,12 @@ void C2Compiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, boo
150161
env->report_failure(C.failure_reason());
151162
continue; // retry
152163
}
164+
if (C.failure_reason_is(retry_no_superword())) {
165+
assert(do_superword, "must make progress");
166+
do_superword = false;
167+
env->report_failure(C.failure_reason());
168+
continue; // retry
169+
}
153170
if (C.has_boxed_value()) {
154171
// Recompile without boxing elimination regardless failure reason.
155172
assert(eliminate_boxing, "must make progress");

src/hotspot/share/opto/c2compiler.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class C2Compiler : public AbstractCompiler {
5252
static const char* retry_no_iterative_escape_analysis();
5353
static const char* retry_no_reduce_allocation_merges();
5454
static const char* retry_no_locks_coarsening();
55+
static const char* retry_no_superword();
5556

5657
// Print compilation timers and statistics
5758
void print_timers();

src/hotspot/share/opto/compile.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,24 @@ class Options {
180180
const bool _do_reduce_allocation_merges; // Do try to reduce allocation merges.
181181
const bool _eliminate_boxing; // Do boxing elimination.
182182
const bool _do_locks_coarsening; // Do locks coarsening
183+
const bool _do_superword; // Do SuperWord
183184
const bool _install_code; // Install the code that was compiled
184185
public:
185-
Options(bool subsume_loads, bool do_escape_analysis,
186+
Options(bool subsume_loads,
187+
bool do_escape_analysis,
186188
bool do_iterative_escape_analysis,
187189
bool do_reduce_allocation_merges,
188-
bool eliminate_boxing, bool do_locks_coarsening,
190+
bool eliminate_boxing,
191+
bool do_locks_coarsening,
192+
bool do_superword,
189193
bool install_code) :
190194
_subsume_loads(subsume_loads),
191195
_do_escape_analysis(do_escape_analysis),
192196
_do_iterative_escape_analysis(do_iterative_escape_analysis),
193197
_do_reduce_allocation_merges(do_reduce_allocation_merges),
194198
_eliminate_boxing(eliminate_boxing),
195199
_do_locks_coarsening(do_locks_coarsening),
200+
_do_superword(do_superword),
196201
_install_code(install_code) {
197202
}
198203

@@ -204,6 +209,7 @@ class Options {
204209
/* do_reduce_allocation_merges = */ false,
205210
/* eliminate_boxing = */ false,
206211
/* do_lock_coarsening = */ false,
212+
/* do_superword = */ true,
207213
/* install_code = */ true
208214
);
209215
}
@@ -578,6 +584,7 @@ class Compile : public Phase {
578584
bool should_install_code() const { return _options._install_code; }
579585
/** Do locks coarsening. */
580586
bool do_locks_coarsening() const { return _options._do_locks_coarsening; }
587+
bool do_superword() const { return _options._do_superword; }
581588

582589
// Other fixed compilation parameters.
583590
ciMethod* method() const { return _method; }

src/hotspot/share/opto/loopTransform.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,8 @@ bool IdealLoopTree::policy_unroll(PhaseIdealLoop *phase) {
933933
// the residual iterations are more than 10% of the trip count
934934
// and rounds of "unroll,optimize" are not making significant progress
935935
// Progress defined as current size less than 20% larger than previous size.
936-
if (UseSuperWord && cl->node_count_before_unroll() > 0 &&
936+
if (phase->C->do_superword() &&
937+
cl->node_count_before_unroll() > 0 &&
937938
future_unroll_cnt > LoopUnrollMin &&
938939
is_residual_iters_large(future_unroll_cnt, cl) &&
939940
1.2 * cl->node_count_before_unroll() < (double)_body.size()) {
@@ -1038,7 +1039,7 @@ bool IdealLoopTree::policy_unroll(PhaseIdealLoop *phase) {
10381039
} // switch
10391040
}
10401041

1041-
if (UseSuperWord) {
1042+
if (phase->C->do_superword()) {
10421043
// Only attempt slp analysis when user controls do not prohibit it
10431044
if (!range_checks_present() && (LoopMaxUnroll > _local_loop_unroll_factor)) {
10441045
// Once policy_slp_analysis succeeds, mark the loop with the

src/hotspot/share/opto/loopUnswitch.cpp

Lines changed: 0 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -284,148 +284,3 @@ void PhaseIdealLoop::verify_fast_loop(LoopNode* head, const ProjNode* proj_true)
284284
}
285285
#endif // ASSERT
286286

287-
LoopNode* PhaseIdealLoop::create_reserve_version_of_loop(IdealLoopTree *loop, CountedLoopReserveKit* lk) {
288-
Node_List old_new;
289-
LoopNode* head = loop->_head->as_Loop();
290-
Node* entry = head->skip_strip_mined()->in(LoopNode::EntryControl);
291-
_igvn.rehash_node_delayed(entry);
292-
IdealLoopTree* outer_loop = head->is_strip_mined() ? loop->_parent->_parent : loop->_parent;
293-
294-
ConINode* const_1 = _igvn.intcon(1);
295-
set_ctrl(const_1, C->root());
296-
IfNode* iff = new IfNode(entry, const_1, PROB_MAX, COUNT_UNKNOWN);
297-
register_node(iff, outer_loop, entry, dom_depth(entry));
298-
ProjNode* iffast = new IfTrueNode(iff);
299-
register_node(iffast, outer_loop, iff, dom_depth(iff));
300-
ProjNode* ifslow = new IfFalseNode(iff);
301-
register_node(ifslow, outer_loop, iff, dom_depth(iff));
302-
303-
// Clone the loop body. The clone becomes the slow loop. The
304-
// original pre-header will (illegally) have 3 control users
305-
// (old & new loops & new if).
306-
clone_loop(loop, old_new, dom_depth(head), CloneIncludesStripMined, iff);
307-
assert(old_new[head->_idx]->is_Loop(), "" );
308-
309-
LoopNode* slow_head = old_new[head->_idx]->as_Loop();
310-
311-
#ifndef PRODUCT
312-
if (TraceLoopOpts) {
313-
tty->print_cr("PhaseIdealLoop::create_reserve_version_of_loop:");
314-
tty->print("\t iff = %d, ", iff->_idx); iff->dump();
315-
tty->print("\t iffast = %d, ", iffast->_idx); iffast->dump();
316-
tty->print("\t ifslow = %d, ", ifslow->_idx); ifslow->dump();
317-
tty->print("\t before replace_input_of: head = %d, ", head->_idx); head->dump();
318-
tty->print("\t before replace_input_of: slow_head = %d, ", slow_head->_idx); slow_head->dump();
319-
}
320-
#endif
321-
322-
// Fast (true) control
323-
_igvn.replace_input_of(head->skip_strip_mined(), LoopNode::EntryControl, iffast);
324-
// Slow (false) control
325-
_igvn.replace_input_of(slow_head->skip_strip_mined(), LoopNode::EntryControl, ifslow);
326-
327-
recompute_dom_depth();
328-
329-
lk->set_iff(iff);
330-
331-
#ifndef PRODUCT
332-
if (TraceLoopOpts ) {
333-
tty->print("\t after replace_input_of: head = %d, ", head->_idx); head->dump();
334-
tty->print("\t after replace_input_of: slow_head = %d, ", slow_head->_idx); slow_head->dump();
335-
}
336-
#endif
337-
338-
return slow_head->as_Loop();
339-
}
340-
341-
CountedLoopReserveKit::CountedLoopReserveKit(PhaseIdealLoop* phase, IdealLoopTree *loop, bool active = true) :
342-
_phase(phase),
343-
_lpt(loop),
344-
_lp(nullptr),
345-
_iff(nullptr),
346-
_lp_reserved(nullptr),
347-
_has_reserved(false),
348-
_use_new(false),
349-
_active(active)
350-
{
351-
create_reserve();
352-
};
353-
354-
CountedLoopReserveKit::~CountedLoopReserveKit() {
355-
if (!_active) {
356-
return;
357-
}
358-
359-
if (_has_reserved && !_use_new) {
360-
// intcon(0)->iff-node reverts CF to the reserved copy
361-
ConINode* const_0 = _phase->_igvn.intcon(0);
362-
_phase->set_ctrl(const_0, _phase->C->root());
363-
_iff->set_req(1, const_0);
364-
365-
#ifndef PRODUCT
366-
if (TraceLoopOpts) {
367-
tty->print_cr("CountedLoopReserveKit::~CountedLoopReserveKit()");
368-
tty->print("\t discard loop %d and revert to the reserved loop clone %d: ", _lp->_idx, _lp_reserved->_idx);
369-
_lp_reserved->dump();
370-
}
371-
#endif
372-
}
373-
}
374-
375-
bool CountedLoopReserveKit::create_reserve() {
376-
if (!_active) {
377-
return false;
378-
}
379-
380-
if(!_lpt->_head->is_CountedLoop()) {
381-
if (TraceLoopOpts) {
382-
tty->print_cr("CountedLoopReserveKit::create_reserve: %d not counted loop", _lpt->_head->_idx);
383-
}
384-
return false;
385-
}
386-
CountedLoopNode *cl = _lpt->_head->as_CountedLoop();
387-
if (!cl->is_valid_counted_loop(T_INT)) {
388-
if (TraceLoopOpts) {
389-
tty->print_cr("CountedLoopReserveKit::create_reserve: %d not valid counted loop", cl->_idx);
390-
}
391-
return false; // skip malformed counted loop
392-
}
393-
if (!cl->is_main_loop()) {
394-
bool loop_not_canonical = true;
395-
if (cl->is_post_loop() && (cl->slp_max_unroll() > 0)) {
396-
loop_not_canonical = false;
397-
}
398-
// only reject some loop forms
399-
if (loop_not_canonical) {
400-
if (TraceLoopOpts) {
401-
tty->print_cr("CountedLoopReserveKit::create_reserve: %d not canonical loop", cl->_idx);
402-
}
403-
return false; // skip normal, pre, and post (conditionally) loops
404-
}
405-
}
406-
407-
_lp = _lpt->_head->as_Loop();
408-
_lp_reserved = _phase->create_reserve_version_of_loop(_lpt, this);
409-
410-
if (!_lp_reserved->is_CountedLoop()) {
411-
return false;
412-
}
413-
414-
Node* ifslow_pred = _lp_reserved->skip_strip_mined()->in(LoopNode::EntryControl);
415-
416-
if (!ifslow_pred->is_IfFalse()) {
417-
return false;
418-
}
419-
420-
Node* iff = ifslow_pred->in(0);
421-
if (!iff->is_If() || iff != _iff) {
422-
return false;
423-
}
424-
425-
if (iff->in(1)->Opcode() != Op_ConI) {
426-
return false;
427-
}
428-
429-
_has_reserved = true;
430-
return true;
431-
}

src/hotspot/share/opto/loopnode.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4640,7 +4640,7 @@ void PhaseIdealLoop::build_and_optimize() {
46404640
}
46414641

46424642
// Convert scalar to superword operations at the end of all loop opts.
4643-
if (UseSuperWord && C->has_loops() && !C->major_progress()) {
4643+
if (C->do_superword() && C->has_loops() && !C->major_progress()) {
46444644
// SuperWord transform
46454645
SuperWord sw(this);
46464646
for (LoopTreeIterator iter(_ltree_root); !iter.done(); iter.next()) {
@@ -5359,11 +5359,12 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) {
53595359
if( !n->is_CallStaticJava() || !n->as_CallStaticJava()->_name ) {
53605360
Node *iff = n->in(0)->in(0);
53615361
// No any calls for vectorized loops.
5362-
if( UseSuperWord || !iff->is_If() ||
5363-
(n->in(0)->Opcode() == Op_IfFalse &&
5364-
(1.0 - iff->as_If()->_prob) >= 0.01) ||
5365-
(iff->as_If()->_prob >= 0.01) )
5362+
if (C->do_superword() ||
5363+
!iff->is_If() ||
5364+
(n->in(0)->Opcode() == Op_IfFalse && (1.0 - iff->as_If()->_prob) >= 0.01) ||
5365+
iff->as_If()->_prob >= 0.01) {
53665366
innermost->_has_call = 1;
5367+
}
53675368
}
53685369
} else if( n->is_Allocate() && n->as_Allocate()->_is_scalar_replaceable ) {
53695370
// Disable loop optimizations if the loop has a scalar replaceable

0 commit comments

Comments
 (0)