8300865: C2: product reduction in ProdRed_Double is not vectorized

Reviewed-by: fgao, epeter, kvn
This commit is contained in:
Sandhya Viswanathan 2023-05-31 22:39:54 +00:00
parent 8eda97dc8d
commit f9ad7df4da
3 changed files with 23 additions and 3 deletions

View File

@ -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++;
}
}

View File

@ -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];

View File

@ -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;