RFR: 8322735: C2: minor improvements of bubble sort used in SuperWord::packset_sort [v2]

Vladimir Kozlov kvn at openjdk.org
Mon Jan 8 21:07:24 UTC 2024


On Fri, 5 Jan 2024 08:57:33 GMT, Denghui Dong <ddong at openjdk.org> wrote:

>> A minor improvement could be made for bubble sort in SuperWord::packset_sort to reduce the comparison count in bad cases.
>> 
>> See https://en.wikipedia.org/wiki/Bubble_sort
>
> Denghui Dong has updated the pull request incrementally with one additional commit since the last revision:
> 
>   update

Clever.

src/hotspot/share/opto/superword.cpp line 3526:

> 3524:       // only swap when we find something to swap
> 3525:       if (alignment(q_low->at(0)) > alignment(q_i->at(0))) {
> 3526:         Node_List* t = q_i;

Why you need this local `t`?

src/hotspot/share/opto/superword.cpp line 3529:

> 3527:         *(_packset.adr_at(i)) = q_low;
> 3528:         *(_packset.adr_at(i-1)) = q_i;
> 3529:         max_swap_index = i;

So we not using `i+1` here because all previous values should be < than `i`'s
Right?

-------------

PR Review: https://git.openjdk.org/jdk/pull/17190#pullrequestreview-1810006561
PR Review Comment: https://git.openjdk.org/jdk/pull/17190#discussion_r1445326103
PR Review Comment: https://git.openjdk.org/jdk/pull/17190#discussion_r1445331241


More information about the hotspot-compiler-dev mailing list