@@ -95,38 +95,48 @@ SuperWord::SuperWord(PhaseIdealLoop* phase) :
95
95
static const bool _do_vector_loop_experimental = false ; // Experimental vectorization which uses data from loop unrolling.
96
96
97
97
// ------------------------------transform_loop---------------------------
98
- void SuperWord::transform_loop (IdealLoopTree* lpt, bool do_optimization) {
98
+ bool SuperWord::transform_loop (IdealLoopTree* lpt, bool do_optimization) {
99
99
assert (UseSuperWord, " should be" );
100
100
// SuperWord only works with power of two vector sizes.
101
101
int vector_width = Matcher::vector_width_in_bytes (T_BYTE);
102
102
if (vector_width < 2 || !is_power_of_2 (vector_width)) {
103
- return ;
103
+ return false ;
104
104
}
105
105
106
106
assert (lpt->_head ->is_CountedLoop (), " must be" );
107
107
CountedLoopNode *cl = lpt->_head ->as_CountedLoop ();
108
108
109
- if (!cl->is_valid_counted_loop (T_INT)) return ; // skip malformed counted loop
109
+ if (!cl->is_valid_counted_loop (T_INT)) {
110
+ return false ; // skip malformed counted loop
111
+ }
110
112
111
113
bool post_loop_allowed = (PostLoopMultiversioning && Matcher::has_predicated_vectors () && cl->is_post_loop ());
112
114
if (post_loop_allowed) {
113
- if (cl->is_reduction_loop ()) return ; // no predication mapping
115
+ if (cl->is_reduction_loop ()) {
116
+ return false ; // no predication mapping
117
+ }
114
118
Node *limit = cl->limit ();
115
- if (limit->is_Con ()) return ; // non constant limits only
119
+ if (limit->is_Con ()) {
120
+ return false ; // non constant limits only
121
+ }
116
122
// Now check the limit for expressions we do not handle
117
123
if (limit->is_Add ()) {
118
124
Node *in2 = limit->in (2 );
119
125
if (in2->is_Con ()) {
120
126
int val = in2->get_int ();
121
127
// should not try to program these cases
122
- if (val < 0 ) return ;
128
+ if (val < 0 ) {
129
+ return false ;
130
+ }
123
131
}
124
132
}
125
133
}
126
134
127
135
// skip any loop that has not been assigned max unroll by analysis
128
136
if (do_optimization) {
129
- if (SuperWordLoopUnrollAnalysis && cl->slp_max_unroll () == 0 ) return ;
137
+ if (SuperWordLoopUnrollAnalysis && cl->slp_max_unroll () == 0 ) {
138
+ return false ;
139
+ }
130
140
}
131
141
132
142
// Check for no control flow in body (other than exit)
@@ -141,28 +151,32 @@ void SuperWord::transform_loop(IdealLoopTree* lpt, bool do_optimization) {
141
151
lpt->dump_head ();
142
152
}
143
153
#endif
144
- return ;
154
+ return false ;
145
155
}
146
156
147
157
// Make sure the are no extra control users of the loop backedge
148
158
if (cl->back_control ()->outcnt () != 1 ) {
149
- return ;
159
+ return false ;
150
160
}
151
161
152
162
// Skip any loops already optimized by slp
153
- if (cl->is_vectorized_loop ()) return ;
163
+ if (cl->is_vectorized_loop ()) {
164
+ return false ;
165
+ }
154
166
155
- if (cl->is_unroll_only ()) return ;
167
+ if (cl->is_unroll_only ()) {
168
+ return false ;
169
+ }
156
170
157
171
if (cl->is_main_loop ()) {
158
172
// Check for pre-loop ending with CountedLoopEnd(Bool(Cmp(x,Opaque1(limit))))
159
173
CountedLoopEndNode* pre_end = find_pre_loop_end (cl);
160
174
if (pre_end == NULL ) {
161
- return ;
175
+ return false ;
162
176
}
163
177
Node* pre_opaq1 = pre_end->limit ();
164
178
if (pre_opaq1->Opcode () != Op_Opaque1) {
165
- return ;
179
+ return false ;
166
180
}
167
181
set_pre_loop_end (pre_end);
168
182
}
@@ -175,9 +189,10 @@ void SuperWord::transform_loop(IdealLoopTree* lpt, bool do_optimization) {
175
189
// For now, define one block which is the entire loop body
176
190
set_bb (cl);
177
191
192
+ bool success = true ;
178
193
if (do_optimization) {
179
194
assert (_packset.length () == 0 , " packset must be empty" );
180
- SLP_extract ();
195
+ success = SLP_extract ();
181
196
if (PostLoopMultiversioning && Matcher::has_predicated_vectors ()) {
182
197
if (cl->is_vectorized_loop () && cl->is_main_loop () && !cl->is_reduction_loop ()) {
183
198
IdealLoopTree *lpt_next = lpt->_next ;
@@ -192,6 +207,7 @@ void SuperWord::transform_loop(IdealLoopTree* lpt, bool do_optimization) {
192
207
}
193
208
}
194
209
}
210
+ return success;
195
211
}
196
212
197
213
// ------------------------------early unrolling analysis------------------------------
@@ -451,7 +467,7 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) {
451
467
// inserting scalar promotion, vector creation from multiple scalars, and
452
468
// extraction of scalar values from vectors.
453
469
//
454
- void SuperWord::SLP_extract () {
470
+ bool SuperWord::SLP_extract () {
455
471
456
472
#ifndef PRODUCT
457
473
if (_do_vector_loop && TraceSuperWord) {
@@ -466,7 +482,7 @@ void SuperWord::SLP_extract() {
466
482
#endif
467
483
// Ready the block
468
484
if (!construct_bb ()) {
469
- return ; // Exit if no interesting nodes or complex graph.
485
+ return false ; // Exit if no interesting nodes or complex graph.
470
486
}
471
487
472
488
// build _dg, _disjoint_ptrs
@@ -483,7 +499,7 @@ void SuperWord::SLP_extract() {
483
499
hoist_loads_in_graph (); // this only rebuild the graph; all basic structs need rebuild explicitly
484
500
485
501
if (!construct_bb ()) {
486
- return ; // Exit if no interesting nodes or complex graph.
502
+ return false ; // Exit if no interesting nodes or complex graph.
487
503
}
488
504
dependence_graph ();
489
505
compute_max_depth ();
@@ -511,7 +527,7 @@ void SuperWord::SLP_extract() {
511
527
find_adjacent_refs ();
512
528
513
529
if (align_to_ref () == NULL ) {
514
- return ; // Did not find memory reference to align vectors
530
+ return false ; // Did not find memory reference to align vectors
515
531
}
516
532
517
533
extend_packlist ();
@@ -563,15 +579,15 @@ void SuperWord::SLP_extract() {
563
579
// map base types for vector usage
564
580
compute_vector_element_type ();
565
581
} else {
566
- return ;
582
+ return false ;
567
583
}
568
584
} else {
569
585
// for some reason we could not map the slp analysis state of the vectorized loop
570
- return ;
586
+ return false ;
571
587
}
572
588
}
573
589
574
- output ();
590
+ return output ();
575
591
}
576
592
577
593
// ------------------------------find_adjacent_refs---------------------------
@@ -2385,17 +2401,11 @@ void SuperWord::print_loop(bool whole) {
2385
2401
2386
2402
// ------------------------------output---------------------------
2387
2403
// Convert packs into vector node operations
2388
- void SuperWord::output () {
2404
+ bool SuperWord::output () {
2389
2405
CountedLoopNode *cl = lpt ()->_head ->as_CountedLoop ();
2390
2406
Compile* C = _phase->C ;
2391
2407
if (_packset.length () == 0 ) {
2392
- if (cl->is_main_loop ()) {
2393
- // Instigate more unrolling for optimization when vectorization fails.
2394
- C->set_major_progress ();
2395
- cl->set_notpassed_slp ();
2396
- cl->mark_do_unroll_only ();
2397
- }
2398
- return ;
2408
+ return false ;
2399
2409
}
2400
2410
2401
2411
#ifndef PRODUCT
@@ -2429,7 +2439,7 @@ void SuperWord::output() {
2429
2439
2430
2440
if (do_reserve_copy () && !make_reversable.has_reserved ()) {
2431
2441
NOT_PRODUCT (if (is_trace_loop_reverse () || TraceLoopOpts) {tty->print_cr (" SWPointer::output: loop was not reserved correctly, exiting SuperWord" );})
2432
- return ;
2442
+ return false ;
2433
2443
}
2434
2444
2435
2445
for (int i = 0 ; i < _block.length (); i++) {
@@ -2474,7 +2484,7 @@ void SuperWord::output() {
2474
2484
if (val == NULL ) {
2475
2485
if (do_reserve_copy ()) {
2476
2486
NOT_PRODUCT (if (is_trace_loop_reverse () || TraceLoopOpts) {tty->print_cr (" SWPointer::output: val should not be NULL, exiting SuperWord" );})
2477
- return ; // and reverse to backup IG
2487
+ return false ; // and reverse to backup IG
2478
2488
}
2479
2489
ShouldNotReachHere ();
2480
2490
}
@@ -2518,7 +2528,7 @@ void SuperWord::output() {
2518
2528
if (in1 == NULL ) {
2519
2529
if (do_reserve_copy ()) {
2520
2530
NOT_PRODUCT (if (is_trace_loop_reverse () || TraceLoopOpts) {tty->print_cr (" SWPointer::output: in1 should not be NULL, exiting SuperWord" );})
2521
- return ; // and reverse to backup IG
2531
+ return false ; // and reverse to backup IG
2522
2532
}
2523
2533
ShouldNotReachHere ();
2524
2534
}
@@ -2527,7 +2537,7 @@ void SuperWord::output() {
2527
2537
if (in2 == NULL ) {
2528
2538
if (do_reserve_copy ()) {
2529
2539
NOT_PRODUCT (if (is_trace_loop_reverse () || TraceLoopOpts) {tty->print_cr (" SWPointer::output: in2 should not be NULL, exiting SuperWord" );})
2530
- return ; // and reverse to backup IG
2540
+ return false ; // and reverse to backup IG
2531
2541
}
2532
2542
ShouldNotReachHere ();
2533
2543
}
@@ -2569,7 +2579,7 @@ void SuperWord::output() {
2569
2579
} else if (is_cmov_pack (p)) {
2570
2580
if (can_process_post_loop) {
2571
2581
// do not refactor of flow in post loop context
2572
- return ;
2582
+ return false ;
2573
2583
}
2574
2584
if (!n->is_CMove ()) {
2575
2585
continue ;
@@ -2586,7 +2596,7 @@ void SuperWord::output() {
2586
2596
if (!bol->is_Bool ()) {
2587
2597
if (do_reserve_copy ()) {
2588
2598
NOT_PRODUCT (if (is_trace_loop_reverse () || TraceLoopOpts) {tty->print_cr (" SWPointer::output: expected %d bool node, exiting SuperWord" , bol->_idx ); bol->dump ();})
2589
- return ; // and reverse to backup IG
2599
+ return false ; // and reverse to backup IG
2590
2600
}
2591
2601
ShouldNotReachHere ();
2592
2602
}
@@ -2602,15 +2612,15 @@ void SuperWord::output() {
2602
2612
if (src1 == NULL ) {
2603
2613
if (do_reserve_copy ()) {
2604
2614
NOT_PRODUCT (if (is_trace_loop_reverse () || TraceLoopOpts) {tty->print_cr (" SWPointer::output: src1 should not be NULL, exiting SuperWord" );})
2605
- return ; // and reverse to backup IG
2615
+ return false ; // and reverse to backup IG
2606
2616
}
2607
2617
ShouldNotReachHere ();
2608
2618
}
2609
2619
Node* src2 = vector_opd (p, 3 ); // 3=CMoveNode::IfTrue
2610
2620
if (src2 == NULL ) {
2611
2621
if (do_reserve_copy ()) {
2612
2622
NOT_PRODUCT (if (is_trace_loop_reverse () || TraceLoopOpts) {tty->print_cr (" SWPointer::output: src2 should not be NULL, exiting SuperWord" );})
2613
- return ; // and reverse to backup IG
2623
+ return false ; // and reverse to backup IG
2614
2624
}
2615
2625
ShouldNotReachHere ();
2616
2626
}
@@ -2634,7 +2644,7 @@ void SuperWord::output() {
2634
2644
} else {
2635
2645
if (do_reserve_copy ()) {
2636
2646
NOT_PRODUCT (if (is_trace_loop_reverse () || TraceLoopOpts) {tty->print_cr (" SWPointer::output: ShouldNotReachHere, exiting SuperWord" );})
2637
- return ; // and reverse to backup IG
2647
+ return false ; // and reverse to backup IG
2638
2648
}
2639
2649
ShouldNotReachHere ();
2640
2650
}
@@ -2643,7 +2653,7 @@ void SuperWord::output() {
2643
2653
if (vn == NULL ) {
2644
2654
if (do_reserve_copy ()){
2645
2655
NOT_PRODUCT (if (is_trace_loop_reverse () || TraceLoopOpts) {tty->print_cr (" SWPointer::output: got NULL node, cannot proceed, exiting SuperWord" );})
2646
- return ; // and reverse to backup IG
2656
+ return false ; // and reverse to backup IG
2647
2657
}
2648
2658
ShouldNotReachHere ();
2649
2659
}
@@ -2661,7 +2671,7 @@ void SuperWord::output() {
2661
2671
// first check if the vector size if the maximum vector which we can use on the machine,
2662
2672
// other vector size have reduced values for predicated data mapping.
2663
2673
if (vlen_in_bytes != (uint )MaxVectorSize) {
2664
- return ;
2674
+ return false ;
2665
2675
}
2666
2676
}
2667
2677
@@ -2734,7 +2744,7 @@ void SuperWord::output() {
2734
2744
make_reversable.use_new ();
2735
2745
}
2736
2746
NOT_PRODUCT (if (is_trace_loop_reverse ()) {tty->print_cr (" \n Final loop after SuperWord" ); print_loop (true );})
2737
- return ;
2747
+ return true ;
2738
2748
}
2739
2749
2740
2750
// ------------------------------vector_opd---------------------------
0 commit comments