Skip to content

Commit

Permalink
8314612: TestUnorderedReduction.java fails with -XX:MaxVectorSize=32 …
Browse files Browse the repository at this point in the history
…and -XX:+AlignVector

Reviewed-by: chagedorn, kvn
  • Loading branch information
eme64 committed Sep 13, 2023
1 parent f8df754 commit f804f86
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/hotspot/share/opto/loopopts.cpp
Expand Up @@ -4275,6 +4275,12 @@ void PhaseIdealLoop::move_unordered_reduction_out_of_loop(IdealLoopTree* loop) {
break; // Chain traversal fails.
}

assert(current->vect_type() != nullptr, "must have vector type");
if (current->vect_type() != last_ur->vect_type()) {
// Reductions do not have the same vector type (length and element type).
break; // Chain traversal fails.
}

// Expect single use of UnorderedReduction, except for last_ur.
if (current == last_ur) {
// Expect all uses to be outside the loop, except phi.
Expand Down
Expand Up @@ -22,11 +22,39 @@
*/

/**
* @test
* @bug 8302652
* @test id=Vanilla-Unaligned
* @bug 8302652 8314612
* @summary Special test cases for PhaseIdealLoop::move_unordered_reduction_out_of_loop
* @requires vm.compiler2.enabled
* @library /test/lib /
* @run driver compiler.loopopts.superword.TestUnorderedReduction
* @run driver compiler.loopopts.superword.TestUnorderedReduction Vanilla-Unaligned
*/

/**
* @test id=Vanilla-Aligned
* @bug 8302652 8314612
* @summary Special test cases for PhaseIdealLoop::move_unordered_reduction_out_of_loop
* @requires vm.compiler2.enabled
* @library /test/lib /
* @run driver compiler.loopopts.superword.TestUnorderedReduction Vanilla-Aligned
*/

/**
* @test id=MaxVectorSize16-Unaligned
* @bug 8302652 8314612
* @summary Special test cases for PhaseIdealLoop::move_unordered_reduction_out_of_loop
* @requires vm.compiler2.enabled
* @library /test/lib /
* @run driver compiler.loopopts.superword.TestUnorderedReduction MaxVectorSize16-Unaligned
*/

/**
* @test id=MaxVectorSize32-Aligned
* @bug 8302652 8314612
* @summary Special test cases for PhaseIdealLoop::move_unordered_reduction_out_of_loop
* @requires vm.compiler2.enabled
* @library /test/lib /
* @run driver compiler.loopopts.superword.TestUnorderedReduction MaxVectorSize32-Aligned
*/

package compiler.loopopts.superword;
Expand All @@ -38,9 +66,22 @@ public class TestUnorderedReduction {
static final int ITER = 10;

public static void main(String[] args) {
TestFramework.runWithFlags("-Xbatch",
"-XX:CompileCommand=compileonly,compiler.loopopts.superword.TestUnorderedReduction::test*",
"-XX:MaxVectorSize=16");
TestFramework framework = new TestFramework(TestUnorderedReduction.class);
framework.addFlags("-Xbatch",
"-XX:CompileCommand=compileonly,compiler.loopopts.superword.TestUnorderedReduction::test*");

if (args.length != 1) {
throw new RuntimeException("Test requires exactly one argument!");
}

switch (args[0]) {
case "Vanilla-Unaligned" -> { framework.addFlags("-XX:-AlignVector"); }
case "Vanilla-Aligned" -> { framework.addFlags("-XX:+AlignVector"); }
case "MaxVectorSize16-Unaligned" -> { framework.addFlags("-XX:-AlignVector", "-XX:MaxVectorSize=16"); }
case "MaxVectorSize32-Aligned" -> { framework.addFlags("-XX:+AlignVector", "-XX:MaxVectorSize=32"); }
default -> { throw new RuntimeException("Test argument not recognized: " + args[0]); }
}
framework.start();
}

@Run(test = {"test1", "test2", "test3"})
Expand Down Expand Up @@ -78,6 +119,7 @@ public void runTests() throws Exception {
@IR(counts = {IRNode.LOAD_VECTOR_I, "> 0",
IRNode.ADD_VI, "= 0",
IRNode.ADD_REDUCTION_VI, "> 0"}, // count can be high
applyIfAnd = {"MaxVectorSize", "=16", "AlignVector", "false"},
applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
static int test1(int[] data, int sum) {
// Vectorizes, but the UnorderedReduction cannot be moved out of the loop,
Expand Down Expand Up @@ -118,6 +160,7 @@ static int ref1(int[] data, int sum) {
IRNode.ADD_VI, "> 0",
IRNode.ADD_REDUCTION_VI, "> 0",
IRNode.ADD_REDUCTION_VI, "<= 2"}, // count must be low
applyIfAnd = {"MaxVectorSize", "=16", "AlignVector", "false"},
applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
static int test2(int[] data, int sum) {
for (int i = 0; i < RANGE; i+=8) {
Expand Down Expand Up @@ -153,6 +196,7 @@ static int ref2(int[] data, int sum) {
IRNode.MUL_VI, "> 0",
IRNode.ADD_VI, "= 0", // reduction not moved out of loop
IRNode.ADD_REDUCTION_VI, "> 0",},
applyIfAnd = {"MaxVectorSize", "=16", "AlignVector", "false"},
applyIfCPUFeatureOr = {"sse4.1", "true", "asimd", "true"})
static int test3(int[] data, int sum) {
for (int i = 0; i < RANGE; i+=8) {
Expand Down

3 comments on commit f804f86

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SoniaZaldana
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on f804f86 Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SoniaZaldana the backport was successfully created on the branch backport-SoniaZaldana-f804f865 in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit f804f865 from the openjdk/jdk repository.

The commit being backported was authored by Emanuel Peter on 13 Sep 2023 and was reviewed by Christian Hagedorn and Vladimir Kozlov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-SoniaZaldana-f804f865:backport-SoniaZaldana-f804f865
$ git checkout backport-SoniaZaldana-f804f865
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-SoniaZaldana-f804f865

Please sign in to comment.