Skip to content

Commit c5e7245

Browse files
committed
8322735: C2: minor improvements of bubble sort used in SuperWord::packset_sort
Reviewed-by: epeter, kvn
1 parent 65a0672 commit c5e7245

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/hotspot/share/opto/superword.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3428,23 +3428,21 @@ void SuperWord::remove_pack_at(int pos) {
34283428

34293429
void SuperWord::packset_sort(int n) {
34303430
// simple bubble sort so that we capitalize with O(n) when its already sorted
3431-
while (n != 0) {
3432-
bool swapped = false;
3431+
do {
3432+
int max_swap_index = 0;
34333433
for (int i = 1; i < n; i++) {
34343434
Node_List* q_low = _packset.at(i-1);
34353435
Node_List* q_i = _packset.at(i);
34363436

34373437
// only swap when we find something to swap
34383438
if (alignment(q_low->at(0)) > alignment(q_i->at(0))) {
3439-
Node_List* t = q_i;
34403439
*(_packset.adr_at(i)) = q_low;
34413440
*(_packset.adr_at(i-1)) = q_i;
3442-
swapped = true;
3441+
max_swap_index = i;
34433442
}
34443443
}
3445-
if (swapped == false) break;
3446-
n--;
3447-
}
3444+
n = max_swap_index;
3445+
} while (n > 1);
34483446
}
34493447

34503448
LoadNode::ControlDependency SuperWord::control_dependency(Node_List* p) {

0 commit comments

Comments
 (0)