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

Backport-of: f804f8652da71b18cc654c08c12d07d6fd43c2a7
  • Loading branch information
Sonia Zaldana Calles authored and jerboaa committed Dec 15, 2023
1 parent 63aecc5 commit db343c9
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
Original file line number Diff line number Diff line change
Expand Up @@ -4237,6 +4237,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
Original file line number Diff line number Diff line change
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, "> 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

1 comment on commit db343c9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.