diff --git a/src/hotspot/share/opto/superword.cpp b/src/hotspot/share/opto/superword.cpp index 23970656d23..ca1d5f41024 100644 --- a/src/hotspot/share/opto/superword.cpp +++ b/src/hotspot/share/opto/superword.cpp @@ -3475,7 +3475,7 @@ bool SuperWord::construct_bb() { // First see if we can map the reduction on the given system we are on, then // make a data entry operation for each reduction we see. BasicType bt = use->bottom_type()->basic_type(); - if (ReductionNode::implemented(use->Opcode(), Matcher::min_vector_size(bt), bt)) { + if (ReductionNode::implemented(use->Opcode(), Matcher::superword_max_vector_size(bt), bt)) { reduction_uses++; } } diff --git a/test/hotspot/jtreg/compiler/loopopts/superword/ProdRed_Double.java b/test/hotspot/jtreg/compiler/loopopts/superword/ProdRed_Double.java index 85c749bb040..ea6939aa694 100644 --- a/test/hotspot/jtreg/compiler/loopopts/superword/ProdRed_Double.java +++ b/test/hotspot/jtreg/compiler/loopopts/superword/ProdRed_Double.java @@ -82,11 +82,12 @@ public class ProdRed_Double { } } - /* Vectorization is expected but not enabled (SuperWord::implemented). - A positive @IR test should be added later. */ @Test @IR(applyIf = {"SuperWordReductions", "false"}, failOn = {IRNode.MUL_REDUCTION_VD}) + @IR(applyIfAnd = {"SuperWordReductions", "true", "LoopMaxUnroll", ">= 8"}, + applyIfCPUFeature = {"sse2", "true"}, + counts = {IRNode.MUL_REDUCTION_VD, ">= 1"}) public static double prodReductionImplement(double[] a, double[] b, double total) { for (int i = 0; i < a.length; i++) { total *= a[i] - b[i]; diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorReduction.java b/test/micro/org/openjdk/bench/vm/compiler/VectorReduction.java index b38330f2b83..9b293b6b7e5 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorReduction.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorReduction.java @@ -46,6 +46,9 @@ public abstract class VectorReduction { private long[] longsB; private long[] longsC; private long[] longsD; + private double[] doublesA; + private double[] doublesB; + private double[] doublesC; @Param("0") private int seed; @@ -63,6 +66,9 @@ public abstract class VectorReduction { longsB = new long[COUNT]; longsC = new long[COUNT]; longsD = new long[COUNT]; + doublesA = new double[COUNT]; + doublesB = new double[COUNT]; + doublesC = new double[COUNT]; for (int i = 0; i < COUNT; i++) { intsA[i] = r.nextInt(); @@ -71,6 +77,9 @@ public abstract class VectorReduction { longsA[i] = r.nextLong(); longsB[i] = r.nextLong(); longsC[i] = r.nextLong(); + doublesA[i] = r.nextDouble(); + doublesB[i] = r.nextDouble(); + doublesC[i] = r.nextDouble(); } } @@ -134,6 +143,16 @@ public abstract class VectorReduction { bh.consume(resL); } + @Benchmark + public void mulRedD(Blackhole bh) { + double resD = 0.0; + for (int i = 0; i < COUNT; i++) { + resD += (doublesA[i] * doublesB[i]) + (doublesA[i] * doublesC[i]) + + (doublesB[i] * doublesC[i]); + } + bh.consume(resD); + } + @Benchmark public void andRedIPartiallyUnrolled(Blackhole bh) { int resI = 0xFFFF;