summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Artem Serov <artem.serov@linaro.org> 2020-04-27 21:09:59 +0100
committer Ulyana Trafimovich <skvadrik@google.com> 2020-07-10 08:22:20 +0000
commit60690e495c3d6ead778bc25c44e925c5fd66173f (patch)
tree6a925353c765fba384e74e9d084d29903431caa3
parent2642cd4bb5308083ac44023f670519350ca96cf4 (diff)
ART: Improve two SIMD tests.
Adds tests to ensure: a) FP and SIMD registers are spilled correctly. b) VecReplicateScalar correctly handles immediates. Test: 655-checker-simd-arm-opt, 623-checker-loop-regressions. Change-Id: If7ce70fd21292ae909ddb5bc78eb85dbe98207be
-rw-r--r--test/623-checker-loop-regressions/src/Main.java106
-rw-r--r--test/655-checker-simd-arm-opt/src/Main.java52
2 files changed, 136 insertions, 22 deletions
diff --git a/test/623-checker-loop-regressions/src/Main.java b/test/623-checker-loop-regressions/src/Main.java
index 36dfc84a72..62f8d5cd97 100644
--- a/test/623-checker-loop-regressions/src/Main.java
+++ b/test/623-checker-loop-regressions/src/Main.java
@@ -577,6 +577,97 @@ public class Main {
s24 + s25 + s26 + s27 + s28 + s29 + s30 + s31;
}
+ // Ensure spilling saves regular FP values correctly when the graph HasSIMD()
+ // is true.
+ /// CHECK-START-ARM64: float Main.$noinline$ensureSlowPathFPSpillFill(float[], float[], float[], float[], int[]) loop_optimization (after)
+ //
+ // Both regular and SIMD accesses are present.
+ /// CHECK-DAG: VecLoad
+ /// CHECK-DAG: ArrayGet
+ private static final float $noinline$ensureSlowPathFPSpillFill(float[] a,
+ float[] b,
+ float[] c,
+ float[] d,
+ int[] e) {
+ // This loop should be vectorized so the graph->HasSIMD() will be true.
+ // A power-of-2 number of iterations is chosen to avoid peeling/unrolling interference.
+ for (int i = 0; i < 64; i++) {
+ // The actual values of the array elements don't matter, just the
+ // presence of a SIMD loop.
+ e[i]++;
+ }
+
+ float f0 = 0;
+ float f1 = 0;
+ float f2 = 0;
+ float f3 = 0;
+ float f4 = 0;
+ float f5 = 0;
+ float f6 = 0;
+ float f7 = 0;
+ float f8 = 0;
+ float f9 = 0;
+ float f10 = 0;
+ float f11 = 0;
+ float f12 = 0;
+ float f13 = 0;
+ float f14 = 0;
+ float f15 = 0;
+ float f16 = 0;
+ float f17 = 0;
+ float f18 = 0;
+ float f19 = 0;
+ float f20 = 0;
+ float f21 = 0;
+ float f22 = 0;
+ float f23 = 0;
+ float f24 = 0;
+ float f25 = 0;
+ float f26 = 0;
+ float f27 = 0;
+ float f28 = 0;
+ float f29 = 0;
+ float f30 = 0;
+ float f31 = 0;
+ for (int i = 0; i < 100; i++) {
+ f0 += a[i];
+ f1 += b[i];
+ f2 += c[i];
+ f3 += d[i];
+ f4 += a[i];
+ f5 += b[i];
+ f6 += c[i];
+ f7 += d[i];
+ f8 += a[i];
+ f9 += b[i];
+ f10 += c[i];
+ f11 += d[i];
+ f12 += a[i];
+ f13 += b[i];
+ f14 += c[i];
+ f15 += d[i];
+ f16 += a[i];
+ f17 += b[i];
+ f18 += c[i];
+ f19 += d[i];
+ f20 += a[i];
+ f21 += b[i];
+ f22 += c[i];
+ f23 += d[i];
+ f24 += a[i];
+ f25 += b[i];
+ f26 += c[i];
+ f27 += d[i];
+ f28 += a[i];
+ f29 += b[i];
+ f30 += c[i];
+ f31 += d[i];
+ }
+ return f0 + f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 + f11 + f12 + f13 + f14 + f15 +
+ f16 + f17 + f18 + f19 + f20 + f21 + f22 + f23 +
+ f24 + f25 + f26 + f27 + f28 + f29 + f30 + f31;
+ }
+
public static int reductionIntoReplication() {
int[] a = { 1, 2, 3, 4 };
int x = 0;
@@ -976,6 +1067,21 @@ public class Main {
}
expectEquals(85800, reduction32Values(a1, a2, a3, a4));
}
+ {
+ float[] a1 = new float[100];
+ float[] a2 = new float[100];
+ float[] a3 = new float[100];
+ float[] a4 = new float[100];
+ int[] a5 = new int[100];
+
+ for (int i = 0; i < 100; i++) {
+ a1[i] = (float)i;
+ a2[i] = (float)1;
+ a3[i] = (float)(100 - i);
+ a4[i] = (i % 16);
+ }
+ expectEquals(86608.0f, $noinline$ensureSlowPathFPSpillFill(a1, a2, a3, a4, a5));
+ }
expectEquals(10, reductionIntoReplication());
diff --git a/test/655-checker-simd-arm-opt/src/Main.java b/test/655-checker-simd-arm-opt/src/Main.java
index 7b61dd7951..c82f24f7ff 100644
--- a/test/655-checker-simd-arm-opt/src/Main.java
+++ b/test/655-checker-simd-arm-opt/src/Main.java
@@ -27,49 +27,57 @@ public class Main {
/// CHECK-START-ARM64: void Main.encodableConstants(byte[], short[], char[], int[], long[], float[], double[]) disassembly (after)
/// CHECK-DAG: <<C1:i\d+>> IntConstant 1
- /// CHECK-DAG: <<C2:i\d+>> IntConstant 2
- /// CHECK-DAG: <<C3:i\d+>> IntConstant 3
- /// CHECK-DAG: <<C4:i\d+>> IntConstant 4
- /// CHECK-DAG: <<L5:j\d+>> LongConstant 5
- /// CHECK-DAG: <<F2:f\d+>> FloatConstant 2
- /// CHECK-DAG: <<D20:d\d+>> DoubleConstant 20
+ /// CHECK-DAG: <<C2:i\d+>> IntConstant -128
+ /// CHECK-DAG: <<C3:i\d+>> IntConstant 127
+ /// CHECK-DAG: <<C4:i\d+>> IntConstant -219
+ /// CHECK-DAG: <<C5:i\d+>> IntConstant 219
+ /// CHECK-DAG: <<L6:j\d+>> LongConstant 219
+ /// CHECK-DAG: <<F7:f\d+>> FloatConstant 2
+ /// CHECK-DAG: <<F8:f\d+>> FloatConstant 14.34
+ /// CHECK-DAG: <<D9:d\d+>> DoubleConstant 20
+ /// CHECK-DAG: <<D10:d\d+>> DoubleConstant 0
//
/// CHECK-DAG: VecReplicateScalar [<<C1>>]
- /// CHECK-DAG: movi v{{[0-9]+}}.16b, #0x1
/// CHECK-DAG: VecReplicateScalar [<<C2>>]
- /// CHECK-DAG: movi v{{[0-9]+}}.8h, #0x2, lsl #0
/// CHECK-DAG: VecReplicateScalar [<<C3>>]
- /// CHECK-DAG: movi v{{[0-9]+}}.8h, #0x3, lsl #0
/// CHECK-DAG: VecReplicateScalar [<<C4>>]
- /// CHECK-DAG: movi v{{[0-9]+}}.4s, #0x4, lsl #0
- /// CHECK-DAG: VecReplicateScalar [<<L5>>]
- /// CHECK-DAG: dup v{{[0-9]+}}.2d, x{{[0-9]+}}
- /// CHECK-DAG: VecReplicateScalar [<<F2>>]
- /// CHECK-DAG: fmov v{{[0-9]+}}.4s, #0x0
- /// CHECK-DAG: VecReplicateScalar [<<D20>>]
- /// CHECK-DAG: fmov v{{[0-9]+}}.2d, #0x34
+ /// CHECK-DAG: VecReplicateScalar [<<C5>>]
+ /// CHECK-DAG: VecReplicateScalar [<<L6>>]
+ /// CHECK-DAG: VecReplicateScalar [<<F7>>]
+ /// CHECK-DAG: VecReplicateScalar [<<F8>>]
+ /// CHECK-DAG: VecReplicateScalar [<<D9>>]
+ /// CHECK-DAG: VecReplicateScalar [<<D10>>]
private static void encodableConstants(byte[] b, short[] s, char[] c, int[] a, long[] l, float[] f, double[] d) {
for (int i = 0; i < ARRAY_SIZE; i++) {
b[i] += 1;
}
for (int i = 0; i < ARRAY_SIZE; i++) {
- s[i] += 2;
+ s[i] += -128;
}
for (int i = 0; i < ARRAY_SIZE; i++) {
- c[i] += 3;
+ c[i] += 127;
}
for (int i = 0; i < ARRAY_SIZE; i++) {
- a[i] += 4;
+ a[i] += -219;
}
for (int i = 0; i < ARRAY_SIZE; i++) {
- l[i] += 5;
+ a[i] += 219;
+ }
+ for (int i = 0; i < ARRAY_SIZE; i++) {
+ l[i] += 219;
}
for (int i = 0; i < ARRAY_SIZE; i++) {
f[i] += 2.0f;
}
for (int i = 0; i < ARRAY_SIZE; i++) {
+ f[i] += 14.34f;
+ }
+ for (int i = 0; i < ARRAY_SIZE; i++) {
d[i] += 20.0;
}
+ for (int i = 0; i < ARRAY_SIZE; i++) {
+ d[i] += 0.0;
+ }
}
private static int sumArray(byte[] b, short[] s, char[] c, int[] a, long[] l, float[] f, double[] d) {
@@ -80,7 +88,7 @@ public class Main {
return sum;
}
- public static final int ARRAY_SIZE = 100;
+ public static final int ARRAY_SIZE = 128;
public static void main(String[] args) {
byte[] b = new byte[ARRAY_SIZE];
@@ -92,7 +100,7 @@ public class Main {
double[] d = new double[ARRAY_SIZE];
encodableConstants(b, s, c, a, l, f, d);
- expectEquals(3700, sumArray(b, s, c, a, l, f, d));
+ expectEquals(32640, sumArray(b, s, c, a, l, f, d));
System.out.println("passed");
}