8298632: [TESTBUG] Add IR checks in jtreg vectorization tests
Reviewed-by: kvn, jbhateja
This commit is contained in:
parent
910dffea86
commit
715b509f3d
@ -130,6 +130,12 @@ public class IRNode {
|
||||
static {
|
||||
beforeMatchingNameRegex(ABS_L, "AbsL");
|
||||
}
|
||||
|
||||
public static final String ABS_V = PREFIX + "ABS_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(ABS_V, "AbsV(B|S|I|L|F|D)");
|
||||
}
|
||||
|
||||
public static final String ADD = PREFIX + "ADD" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(ADD, "Add(I|L|F|D|P)");
|
||||
@ -145,6 +151,11 @@ public class IRNode {
|
||||
beforeMatchingNameRegex(ADD_L, "AddL");
|
||||
}
|
||||
|
||||
public static final String ADD_V = PREFIX + "ADD_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(ADD_V, "AddV(B|S|I|L|F|D)");
|
||||
}
|
||||
|
||||
public static final String ADD_VD = PREFIX + "ADD_VD" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(ADD_VD, "AddVD");
|
||||
@ -155,6 +166,11 @@ public class IRNode {
|
||||
beforeMatchingNameRegex(ADD_VI, "AddVI");
|
||||
}
|
||||
|
||||
public static final String ADD_REDUCTION_V = PREFIX + "ADD_REDUCTION_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(ADD_REDUCTION_V, "AddReductionV(B|S|I|L|F|D)");
|
||||
}
|
||||
|
||||
public static final String ADD_REDUCTION_VD = PREFIX + "ADD_REDUCTION_VD" + POSTFIX;
|
||||
static {
|
||||
superWordNodes(ADD_REDUCTION_VD, "AddReductionVD");
|
||||
@ -360,6 +376,11 @@ public class IRNode {
|
||||
beforeMatchingNameRegex(DIV_L, "DivL");
|
||||
}
|
||||
|
||||
public static final String DIV_V = PREFIX + "DIV_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(DIV_V, "DivV(F|D)");
|
||||
}
|
||||
|
||||
public static final String DYNAMIC_CALL_OF_METHOD = COMPOSITE_PREFIX + "DYNAMIC_CALL_OF_METHOD" + POSTFIX;
|
||||
static {
|
||||
callOfNodes(DYNAMIC_CALL_OF_METHOD, "CallDynamicJava");
|
||||
@ -387,6 +408,11 @@ public class IRNode {
|
||||
optoOnly(FIELD_ACCESS, regex);
|
||||
}
|
||||
|
||||
public static final String FMA_V = PREFIX + "FMA_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(FMA_V, "FmaV(F|D)");
|
||||
}
|
||||
|
||||
public static final String IF = PREFIX + "IF" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(IF, "If\\b");
|
||||
@ -588,6 +614,11 @@ public class IRNode {
|
||||
beforeMatchingNameRegex(LSHIFT_L, "LShiftL");
|
||||
}
|
||||
|
||||
public static final String LSHIFT_V = PREFIX + "LSHIFT_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(LSHIFT_V, "LShiftV(B|S|I|L)");
|
||||
}
|
||||
|
||||
public static final String MACRO_LOGIC_V = PREFIX + "MACRO_LOGIC_V" + POSTFIX;
|
||||
static {
|
||||
afterBarrierExpansionToBeforeMatching(MACRO_LOGIC_V, "MacroLogicV");
|
||||
@ -658,6 +689,11 @@ public class IRNode {
|
||||
beforeMatchingNameRegex(MUL_L, "MulL");
|
||||
}
|
||||
|
||||
public static final String MUL_V = PREFIX + "MUL_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(MUL_V, "MulV(B|S|I|L|F|D)");
|
||||
}
|
||||
|
||||
public static final String MUL_VL = PREFIX + "MUL_VL" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(MUL_VL, "MulVL");
|
||||
@ -673,6 +709,11 @@ public class IRNode {
|
||||
superWordNodes(MUL_REDUCTION_VF, "MulReductionVF");
|
||||
}
|
||||
|
||||
public static final String NEG_V = PREFIX + "NEG_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(NEG_V, "NegV(F|D)");
|
||||
}
|
||||
|
||||
public static final String NULL_ASSERT_TRAP = PREFIX + "NULL_ASSERT_TRAP" + POSTFIX;
|
||||
static {
|
||||
trapNodes(NULL_ASSERT_TRAP,"null_assert");
|
||||
@ -709,6 +750,11 @@ public class IRNode {
|
||||
beforeMatchingNameRegex(POPCOUNT_L, "PopCountL");
|
||||
}
|
||||
|
||||
public static final String POPCOUNT_VI = PREFIX + "POPCOUNT_VI" + POSTFIX;
|
||||
static {
|
||||
superWordNodes(POPCOUNT_VI, "PopCountVI");
|
||||
}
|
||||
|
||||
public static final String POPCOUNT_VL = PREFIX + "POPCOUNT_VL" + POSTFIX;
|
||||
static {
|
||||
superWordNodes(POPCOUNT_VL, "PopCountVL");
|
||||
@ -742,6 +788,54 @@ public class IRNode {
|
||||
trapNodes(RANGE_CHECK_TRAP,"range_check");
|
||||
}
|
||||
|
||||
public static final String REPLICATE_B = PREFIX + "REPLICATE_B" + POSTFIX;
|
||||
static {
|
||||
String regex = START + "ReplicateB" + MID + END;
|
||||
IR_NODE_MAPPINGS.put(REPLICATE_B, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
|
||||
CompilePhase.AFTER_CLOOPS,
|
||||
CompilePhase.BEFORE_MATCHING));
|
||||
}
|
||||
|
||||
public static final String REPLICATE_S = PREFIX + "REPLICATE_S" + POSTFIX;
|
||||
static {
|
||||
String regex = START + "ReplicateS" + MID + END;
|
||||
IR_NODE_MAPPINGS.put(REPLICATE_S, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
|
||||
CompilePhase.AFTER_CLOOPS,
|
||||
CompilePhase.BEFORE_MATCHING));
|
||||
}
|
||||
|
||||
public static final String REPLICATE_I = PREFIX + "REPLICATE_I" + POSTFIX;
|
||||
static {
|
||||
String regex = START + "ReplicateI" + MID + END;
|
||||
IR_NODE_MAPPINGS.put(REPLICATE_I, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
|
||||
CompilePhase.AFTER_CLOOPS,
|
||||
CompilePhase.BEFORE_MATCHING));
|
||||
}
|
||||
|
||||
public static final String REPLICATE_L = PREFIX + "REPLICATE_L" + POSTFIX;
|
||||
static {
|
||||
String regex = START + "ReplicateL" + MID + END;
|
||||
IR_NODE_MAPPINGS.put(REPLICATE_L, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
|
||||
CompilePhase.AFTER_CLOOPS,
|
||||
CompilePhase.BEFORE_MATCHING));
|
||||
}
|
||||
|
||||
public static final String REPLICATE_F = PREFIX + "REPLICATE_F" + POSTFIX;
|
||||
static {
|
||||
String regex = START + "ReplicateF" + MID + END;
|
||||
IR_NODE_MAPPINGS.put(REPLICATE_F, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
|
||||
CompilePhase.AFTER_CLOOPS,
|
||||
CompilePhase.BEFORE_MATCHING));
|
||||
}
|
||||
|
||||
public static final String REPLICATE_D = PREFIX + "REPLICATE_D" + POSTFIX;
|
||||
static {
|
||||
String regex = START + "ReplicateD" + MID + END;
|
||||
IR_NODE_MAPPINGS.put(REPLICATE_D, new SinglePhaseRangeEntry(CompilePhase.PRINT_IDEAL, regex,
|
||||
CompilePhase.AFTER_CLOOPS,
|
||||
CompilePhase.BEFORE_MATCHING));
|
||||
}
|
||||
|
||||
public static final String REVERSE_BYTES_V = PREFIX + "REVERSE_BYTES_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(REVERSE_BYTES_V, "ReverseBytesV");
|
||||
@ -782,6 +876,21 @@ public class IRNode {
|
||||
beforeMatchingNameRegex(ROTATE_RIGHT, "RotateRight");
|
||||
}
|
||||
|
||||
public static final String ROTATE_LEFT_V = PREFIX + "ROTATE_LEFT_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(ROTATE_LEFT_V, "RotateLeftV");
|
||||
}
|
||||
|
||||
public static final String ROTATE_RIGHT_V = PREFIX + "ROTATE_RIGHT_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(ROTATE_RIGHT_V, "RotateRightV");
|
||||
}
|
||||
|
||||
public static final String ROUND_DOUBLE_MODE_V = PREFIX + "ROUND_DOUBLE_MODE_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(ROUND_DOUBLE_MODE_V, "RoundDoubleModeV");
|
||||
}
|
||||
|
||||
public static final String RSHIFT = PREFIX + "RSHIFT" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(RSHIFT, "RShift(I|L)");
|
||||
@ -807,6 +916,11 @@ public class IRNode {
|
||||
beforeMatchingNameRegex(RSHIFT_VS, "RShiftVS");
|
||||
}
|
||||
|
||||
public static final String RSHIFT_V = PREFIX + "RSHIFT_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(RSHIFT_V, "RShiftV(B|S|I|L)");
|
||||
}
|
||||
|
||||
public static final String SAFEPOINT = PREFIX + "SAFEPOINT" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(SAFEPOINT, "SafePoint");
|
||||
@ -828,6 +942,11 @@ public class IRNode {
|
||||
beforeMatchingNameRegex(SIGNUM_VF, "SignumVF");
|
||||
}
|
||||
|
||||
public static final String SQRT_V = PREFIX + "SQRT_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(SQRT_V, "SqrtV(F|D)");
|
||||
}
|
||||
|
||||
public static final String STORE = PREFIX + "STORE" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(STORE, "Store(B|C|S|I|L|F|D|P|N)");
|
||||
@ -964,6 +1083,11 @@ public class IRNode {
|
||||
beforeMatchingNameRegex(SUB_L, "SubL");
|
||||
}
|
||||
|
||||
public static final String SUB_V = PREFIX + "SUB_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(SUB_V, "SubV(B|S|I|L|F|D)");
|
||||
}
|
||||
|
||||
public static final String TRAP = PREFIX + "TRAP" + POSTFIX;
|
||||
static {
|
||||
trapNodes(TRAP,"reason");
|
||||
@ -1034,6 +1158,11 @@ public class IRNode {
|
||||
beforeMatchingNameRegex(URSHIFT_S, "URShiftS");
|
||||
}
|
||||
|
||||
public static final String URSHIFT_V = PREFIX + "URSHIFT_V" + POSTFIX;
|
||||
static {
|
||||
beforeMatchingNameRegex(URSHIFT_V, "URShiftV(B|S|I|L)");
|
||||
}
|
||||
|
||||
public static final String VAND_NOT_I = PREFIX + "VAND_NOT_I" + POSTFIX;
|
||||
static {
|
||||
machOnlyNameRegex(VAND_NOT_I, "vand_notI");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,9 +40,11 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private byte[] bytes;
|
||||
private short[] shorts;
|
||||
@ -73,6 +75,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Simple Copy ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public byte[] copyByteArray() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -82,6 +86,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public short[] copyShortArray() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -91,6 +97,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public char[] copyCharArray() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -100,6 +108,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] copyIntArray() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -109,6 +119,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public long[] copyLongArray() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -118,6 +130,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public float[] copyFloatArray() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -127,6 +141,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public double[] copyDoubleArray() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -137,6 +153,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Multiple Copies ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public float[] chainedCopy() {
|
||||
float[] res1 = new float[SIZE];
|
||||
float[] res2 = new float[SIZE];
|
||||
@ -147,6 +165,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] copy2ArraysSameSize() {
|
||||
int[] res1 = new int[SIZE];
|
||||
float[] res2 = new float[SIZE];
|
||||
@ -158,6 +178,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public double[] copy2ArraysDifferentSizes() {
|
||||
int[] res1 = new int[SIZE];
|
||||
double[] res2 = new double[SIZE];
|
||||
@ -170,6 +192,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Copy Between Signed & Unsigned ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public char[] copyFromSignedToUnsigned() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -179,6 +203,8 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public short[] copyFromUnsignedToSigned() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -187,4 +213,3 @@ public class ArrayCopyTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,9 +40,11 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class ArrayIndexFillTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private int[] a;
|
||||
|
||||
@ -54,6 +56,8 @@ public class ArrayIndexFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
|
||||
counts = {IRNode.POPULATE_INDEX, ">0"})
|
||||
public byte[] fillByteArray() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -63,6 +67,8 @@ public class ArrayIndexFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
|
||||
counts = {IRNode.POPULATE_INDEX, ">0"})
|
||||
public short[] fillShortArray() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -72,6 +78,8 @@ public class ArrayIndexFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
|
||||
counts = {IRNode.POPULATE_INDEX, ">0"})
|
||||
public char[] fillCharArray() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -81,6 +89,8 @@ public class ArrayIndexFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
|
||||
counts = {IRNode.POPULATE_INDEX, ">0"})
|
||||
public int[] fillIntArray() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -99,6 +109,8 @@ public class ArrayIndexFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
|
||||
counts = {IRNode.POPULATE_INDEX, ">0"})
|
||||
public short[] fillShortArrayWithShortIndex() {
|
||||
short[] res = new short[SIZE];
|
||||
for (short i = 0; i < SIZE; i++) {
|
||||
@ -108,6 +120,8 @@ public class ArrayIndexFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
|
||||
counts = {IRNode.POPULATE_INDEX, ">0"})
|
||||
public int[] fillMultipleArraysDifferentTypes1() {
|
||||
int[] res1 = new int[SIZE];
|
||||
short[] res2 = new short[SIZE];
|
||||
@ -119,6 +133,8 @@ public class ArrayIndexFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
|
||||
counts = {IRNode.POPULATE_INDEX, ">0"})
|
||||
public char[] fillMultipleArraysDifferentTypes2() {
|
||||
int[] res1 = new int[SIZE];
|
||||
char[] res2 = new char[SIZE];
|
||||
@ -139,4 +155,3 @@ public class ArrayIndexFillTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -41,11 +41,13 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private int intInv;
|
||||
private char charInv;
|
||||
@ -62,6 +64,8 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Simple Fill ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.REPLICATE_B, ">0"})
|
||||
public byte[] fillByteArray() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -71,6 +75,8 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.REPLICATE_S, ">0"})
|
||||
public short[] fillShortArray() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -80,6 +86,8 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.REPLICATE_S, ">0"})
|
||||
public char[] fillCharArray() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -89,6 +97,8 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.REPLICATE_I, ">0"})
|
||||
public int[] fillIntArray() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -98,6 +108,8 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.REPLICATE_L, ">0"})
|
||||
public long[] fillLongArray() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -107,6 +119,8 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.REPLICATE_F, ">0"})
|
||||
public float[] fillFloatArray() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -116,6 +130,8 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.REPLICATE_D, ">0"})
|
||||
public double[] fillDoubleArray() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -126,6 +142,8 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Fill With Type Change ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.REPLICATE_L, ">0"})
|
||||
public long[] fillLongArrayWithInt() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -135,6 +153,8 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.REPLICATE_L, ">0"})
|
||||
public long[] fillLongArrayWithUnsigned() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -144,6 +164,8 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.REPLICATE_L, ">0"})
|
||||
public long[] fillLongArrayWithFloat() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -153,6 +175,8 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.REPLICATE_I, ">0"})
|
||||
public int[] fillIntArrayWithDouble() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -161,4 +185,3 @@ public class ArrayInvariantFillTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,11 +40,13 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ArrayShiftOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private int[] ints;
|
||||
private long[] longs;
|
||||
@ -68,6 +70,10 @@ public class ArrayShiftOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
@IR(applyIfCPUFeature = {"avx512f", "true"},
|
||||
counts = {IRNode.ROTATE_RIGHT_V, ">0"})
|
||||
public int[] intCombinedRotateShift() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -77,6 +83,10 @@ public class ArrayShiftOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
@IR(applyIfCPUFeature = {"avx512f", "true"},
|
||||
counts = {IRNode.ROTATE_RIGHT_V, ">0"})
|
||||
public long[] longCombinedRotateShift() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -86,6 +96,8 @@ public class ArrayShiftOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.RSHIFT_V, ">0"})
|
||||
public int[] intShiftLargeDistConstant() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -95,6 +107,8 @@ public class ArrayShiftOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.RSHIFT_V, ">0"})
|
||||
public int[] intShiftLargeDistInvariant() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -104,6 +118,30 @@ public class ArrayShiftOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.RSHIFT_V, ">0"})
|
||||
public short[] shortShiftLargeDistConstant() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
res[i] = (short) (shorts1[i] >> 65);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.RSHIFT_V, ">0"})
|
||||
public short[] shortShiftLargeDistInvariant() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
res[i] = (short) (shorts2[i] >> (largeDist - 25));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.LSHIFT_V, ">0"})
|
||||
public long[] longShiftLargeDistConstant() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -113,6 +151,8 @@ public class ArrayShiftOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.URSHIFT_V, ">0"})
|
||||
public long[] longShiftLargeDistInvariant() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -122,8 +162,8 @@ public class ArrayShiftOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that any shift operation with distance value from another array
|
||||
// cannot be vectorized since C2 vector shift node doesn't support it.
|
||||
// Note that shift with variant distance cannot be vectorized.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public long[] variantShiftDistance() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -133,6 +173,19 @@ public class ArrayShiftOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that shift with variant distance cannot be vectorized.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public short[] loopIndexShiftDistance() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
res[i] = (short) (shorts1[i] >> i);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.RSHIFT_V, ">0"})
|
||||
public short[] vectorUnsignedShiftRight() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -143,7 +196,8 @@ public class ArrayShiftOpTest extends VectorizationTestRunner {
|
||||
|
||||
@Test
|
||||
// Note that right shift operations on subword expressions cannot be
|
||||
// vectorized since precise type info about signness is missing.
|
||||
// vectorized since precise type info about signedness is missing.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public short[] subwordExpressionRightShift() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -152,4 +206,3 @@ public class ArrayShiftOpTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,9 +40,11 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private byte[] bytes;
|
||||
private short[] shorts;
|
||||
@ -129,6 +131,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Convert I/L to F/D ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_I2X, ">0"})
|
||||
public float[] convertIntToFloat() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -138,6 +142,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_I2X, ">0"})
|
||||
public double[] convertIntToDouble() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -147,6 +153,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx512dq", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_L2X, ">0"})
|
||||
public float[] convertLongToFloat() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -156,6 +164,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx512dq", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_L2X, ">0"})
|
||||
public double[] convertLongToDouble() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -166,6 +176,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Convert Subword-I to F/D ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_S2X, ">0"})
|
||||
public float[] convertShortToFloat() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -175,6 +187,9 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
|
||||
applyIf = {"MaxVectorSize", ">=32"},
|
||||
counts = {IRNode.VECTOR_CAST_S2X, ">0"})
|
||||
public double[] convertShortToDouble() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -203,6 +218,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Convert F/D to I/L ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_F2X, ">0"})
|
||||
public int[] convertFloatToInt() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -212,6 +229,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx512dq", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_F2X, ">0"})
|
||||
public long[] convertFloatToLong() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -221,6 +240,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_D2X, ">0"})
|
||||
public int[] convertDoubleToInt() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -230,6 +251,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx512dq", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_D2X, ">0"})
|
||||
public long[] convertDoubleToLong() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -240,6 +263,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Convert F/D to Subword-I ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_F2X, ">0"})
|
||||
public short[] convertFloatToShort() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -249,6 +274,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_F2X, ">0"})
|
||||
public char[] convertFloatToChar() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -258,6 +285,9 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx", "true"},
|
||||
applyIf = {"MaxVectorSize", ">=32"},
|
||||
counts = {IRNode.VECTOR_CAST_D2X, ">0"})
|
||||
public short[] convertDoubleToShort() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -267,6 +297,9 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx", "true"},
|
||||
applyIf = {"MaxVectorSize", ">=32"},
|
||||
counts = {IRNode.VECTOR_CAST_D2X, ">0"})
|
||||
public char[] convertDoubleToChar() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -277,6 +310,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Convert Between F & D ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_F2X, ">0"})
|
||||
public double[] convertFloatToDouble() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -286,6 +321,8 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"},
|
||||
counts = {IRNode.VECTOR_CAST_D2X, ">0"})
|
||||
public float[] convertDoubleToFloat() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -294,4 +331,3 @@ public class ArrayTypeConvertTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,13 +40,15 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
public class ArrayUnsafeOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private static Unsafe unsafe;
|
||||
|
||||
@ -92,6 +94,7 @@ public class ArrayUnsafeOpTest extends VectorizationTestRunner {
|
||||
// Note that this case cannot be vectorized since data dependence
|
||||
// exists between adjacent iterations. (The memory address storing
|
||||
// an int array is not increased by 4 per iteration.)
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public int[] arrayUnsafeFillAddrIncrMismatch() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < 500; i++) {
|
||||
@ -100,4 +103,3 @@ public class ArrayUnsafeOpTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,9 +40,11 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class BasicBooleanOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private boolean[] a;
|
||||
private boolean[] b;
|
||||
@ -69,6 +71,10 @@ public class BasicBooleanOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeature = {"asimd", "true"},
|
||||
counts = {IRNode.AND_V, ">0"})
|
||||
@IR(applyIfCPUFeature = {"avx512vl", "true"},
|
||||
counts = {IRNode.MACRO_LOGIC_V, ">0"})
|
||||
public boolean[] vectorAnd() {
|
||||
boolean[] res = new boolean[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -78,6 +84,8 @@ public class BasicBooleanOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.OR_V, ">0"})
|
||||
public boolean[] vectorOr() {
|
||||
boolean[] res = new boolean[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -87,6 +95,8 @@ public class BasicBooleanOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.XOR_V, ">0"})
|
||||
public boolean[] vectorXor() {
|
||||
boolean[] res = new boolean[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -95,4 +105,3 @@ public class BasicBooleanOpTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,9 +40,11 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private byte[] a;
|
||||
private byte[] b;
|
||||
@ -61,6 +63,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Arithmetic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public byte[] vectorNeg() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -70,6 +74,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "ssse3", "true"},
|
||||
counts = {IRNode.ABS_V, ">0"})
|
||||
public byte[] vectorAbs() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -79,6 +85,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.ADD_V, ">0"})
|
||||
public byte[] vectorAdd() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -88,6 +96,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public byte[] vectorSub() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -97,6 +107,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public byte[] vectorMul() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -106,6 +118,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0", IRNode.ADD_V, ">0"})
|
||||
public byte[] vectorMulAdd() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -115,6 +129,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0", IRNode.SUB_V, ">0"})
|
||||
public byte[] vectorMulSub() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -125,6 +141,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Logic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.XOR_V, ">0"})
|
||||
public byte[] vectorNot() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -134,6 +152,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.AND_V, ">0"})
|
||||
public byte[] vectorAnd() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -143,6 +163,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.OR_V, ">0"})
|
||||
public byte[] vectorOr() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -152,6 +174,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.XOR_V, ">0"})
|
||||
public byte[] vectorXor() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -162,6 +186,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Shift ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.LSHIFT_V, ">0"})
|
||||
public byte[] vectorShiftLeft() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -171,6 +197,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.RSHIFT_V, ">0"})
|
||||
public byte[] vectorSignedShiftRight() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -180,6 +208,8 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.RSHIFT_V, ">0"})
|
||||
public byte[] vectorUnsignedShiftRight() {
|
||||
byte[] res = new byte[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -188,4 +218,3 @@ public class BasicByteOpTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,9 +40,11 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private char[] a;
|
||||
private char[] b;
|
||||
@ -64,6 +66,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Arithmetic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public char[] vectorNeg() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -73,8 +77,9 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that Math.abs() on unsigned subword types can NOT be vectorized
|
||||
// since all the values are non-negative according to the semantics.
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
@IR(failOn = {IRNode.ABS_V})
|
||||
public char[] vectorAbs() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -84,6 +89,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.ADD_V, ">0"})
|
||||
public char[] vectorAdd() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -93,6 +100,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public char[] vectorSub() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -102,6 +111,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public char[] vectorMul() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -111,6 +122,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0", IRNode.ADD_V, ">0"})
|
||||
public char[] vectorMulAdd() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -120,6 +133,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0", IRNode.SUB_V, ">0"})
|
||||
public char[] vectorMulSub() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -130,6 +145,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Logic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.XOR_V, ">0"})
|
||||
public char[] vectorNot() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -139,6 +156,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.AND_V, ">0"})
|
||||
public char[] vectorAnd() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -148,6 +167,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.OR_V, ">0"})
|
||||
public char[] vectorOr() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -157,6 +178,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.XOR_V, ">0"})
|
||||
public char[] vectorXor() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -167,6 +190,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Shift ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.LSHIFT_V, ">0"})
|
||||
public char[] vectorShiftLeft() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -176,6 +201,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.URSHIFT_V, ">0"})
|
||||
public char[] vectorSignedShiftRight() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -185,6 +212,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.URSHIFT_V, ">0"})
|
||||
public char[] vectorUnsignedShiftRight() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -195,6 +224,8 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ------------- ReverseBytes -------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx2", "true"},
|
||||
counts = {IRNode.REVERSE_BYTES_V, ">0"})
|
||||
public char[] reverseBytesWithChar() {
|
||||
char[] res = new char[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -204,6 +235,9 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that reverseBytes cannot be vectorized if the vector element
|
||||
// type doesn't match the caller's class type.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public int[] reverseBytesWithInt() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -212,4 +246,3 @@ public class BasicCharOpTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,9 +40,11 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private double[] a;
|
||||
private double[] b;
|
||||
@ -61,6 +63,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Arithmetic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.NEG_V, ">0"})
|
||||
public double[] vectorNeg() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -70,6 +74,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.ABS_V, ">0"})
|
||||
public double[] vectorAbs() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -79,6 +85,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"},
|
||||
counts = {IRNode.SQRT_V, ">0"})
|
||||
public double[] vectorSqrt() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -88,6 +96,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse", "true"},
|
||||
counts = {IRNode.ROUND_DOUBLE_MODE_V, ">0"})
|
||||
public double[] vectorCeil() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -97,6 +107,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse4_1", "true"},
|
||||
counts = {IRNode.ROUND_DOUBLE_MODE_V, ">0"})
|
||||
public double[] vectorFloor() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -106,6 +118,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse4_1", "true"},
|
||||
counts = {IRNode.ROUND_DOUBLE_MODE_V, ">0"})
|
||||
public double[] vectorRint() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -115,6 +129,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.ADD_V, ">0"})
|
||||
public double[] vectorAdd() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -124,6 +140,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public double[] vectorSub() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -133,6 +151,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public double[] vectorMul() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -142,6 +162,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.DIV_V, ">0"})
|
||||
public double[] vectorDiv() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -151,6 +173,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse", "true"},
|
||||
counts = {IRNode.MAX_V, ">0"})
|
||||
public double[] vectorMax() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -160,6 +184,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse", "true"},
|
||||
counts = {IRNode.MIN_V, ">0"})
|
||||
public double[] vectorMin() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -169,6 +195,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public double[] vectorMulAdd() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -178,6 +206,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public double[] vectorMulSub1() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -187,6 +217,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public double[] vectorMulSub2() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -196,6 +228,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public double[] vectorNegateMulAdd1() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -205,6 +239,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public double[] vectorNegateMulAdd2() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -214,6 +250,8 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public double[] vectorNegateMulSub() {
|
||||
double[] res = new double[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -250,4 +288,3 @@ public class BasicDoubleOpTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,9 +40,11 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private float[] a;
|
||||
private float[] b;
|
||||
@ -61,6 +63,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Arithmetic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse", "true"},
|
||||
counts = {IRNode.NEG_V, ">0"})
|
||||
public float[] vectorNeg() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -70,6 +74,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse", "true"},
|
||||
counts = {IRNode.ABS_V, ">0"})
|
||||
public float[] vectorAbs() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -79,6 +85,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx", "true"},
|
||||
counts = {IRNode.SQRT_V, ">0"})
|
||||
public float[] vectorSqrt() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -88,6 +96,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.ADD_V, ">0"})
|
||||
public float[] vectorAdd() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -97,6 +107,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public float[] vectorSub() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -106,6 +118,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public float[] vectorMul() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -115,6 +129,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.DIV_V, ">0"})
|
||||
public float[] vectorDiv() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -124,6 +140,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse", "true"},
|
||||
counts = {IRNode.MAX_V, ">0"})
|
||||
public float[] vectorMax() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -133,6 +151,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse", "true"},
|
||||
counts = {IRNode.MIN_V, ">0"})
|
||||
public float[] vectorMin() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -142,6 +162,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public float[] vectorMulAdd() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -151,6 +173,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public float[] vectorMulSub1() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -160,6 +184,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public float[] vectorMulSub2() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -169,6 +195,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public float[] vectorNegateMulAdd1() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -178,6 +206,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public float[] vectorNegateMulAdd2() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -187,6 +217,8 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "fma", "true"},
|
||||
counts = {IRNode.FMA_V, ">0"})
|
||||
public float[] vectorNegateMulSub() {
|
||||
float[] res = new float[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -223,4 +255,3 @@ public class BasicFloatOpTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,9 +40,11 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private int[] a;
|
||||
private int[] b;
|
||||
@ -61,6 +63,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Arithmetic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public int[] vectorNeg() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -70,6 +74,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "ssse3", "true"},
|
||||
counts = {IRNode.ABS_V, ">0"})
|
||||
public int[] vectorAbs() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -79,6 +85,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.ADD_V, ">0"})
|
||||
public int[] vectorAdd() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -88,6 +96,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public int[] vectorSub() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -97,6 +107,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse4_1", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public int[] vectorMul() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -106,6 +118,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse4_1", "true"},
|
||||
counts = {IRNode.MUL_V, ">0", IRNode.ADD_V, ">0"})
|
||||
public int[] vectorMulAdd() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -115,6 +129,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse4_1", "true"},
|
||||
counts = {IRNode.MUL_V, ">0", IRNode.SUB_V, ">0"})
|
||||
public int[] vectorMulSub() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -124,6 +140,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx2", "true"},
|
||||
counts = {IRNode.POPCOUNT_VI, ">0"})
|
||||
public int[] vectorPopCount() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -134,6 +152,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Logic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.XOR_V, ">0"})
|
||||
public int[] vectorNot() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -143,6 +163,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.AND_V, ">0"})
|
||||
public int[] vectorAnd() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -152,6 +174,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.OR_V, ">0"})
|
||||
public int[] vectorOr() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -161,6 +185,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.XOR_V, ">0"})
|
||||
public int[] vectorXor() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -171,6 +197,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Shift ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.LSHIFT_V, ">0"})
|
||||
public int[] vectorShiftLeft() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -180,6 +208,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.RSHIFT_V, ">0"})
|
||||
public int[] vectorSignedShiftRight() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -189,6 +219,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.URSHIFT_V, ">0"})
|
||||
public int[] vectorUnsignedShiftRight() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -235,6 +267,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that integer max produces non-vectorizable CMoveI node.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public int reductionMax() {
|
||||
int res = Integer.MIN_VALUE;
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -244,6 +278,8 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that integer min produces non-vectorizable CMoveI node.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public int reductionMin() {
|
||||
int res = Integer.MAX_VALUE;
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -252,4 +288,3 @@ public class BasicIntOpTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,9 +40,11 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private long[] a;
|
||||
private long[] b;
|
||||
@ -61,6 +63,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Arithmetic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public long[] vectorNeg() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -70,6 +74,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx512vl", "true"},
|
||||
counts = {IRNode.ABS_V, ">0"})
|
||||
public long[] vectorAbs() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -79,6 +85,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.ADD_V, ">0"})
|
||||
public long[] vectorAdd() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -88,6 +96,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public long[] vectorSub() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -97,6 +107,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx512dq", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public long[] vectorMul() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -106,6 +118,10 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "sse2", "true"},
|
||||
counts = {IRNode.ADD_V, ">0"})
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx512dq", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public long[] vectorMulAdd() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -115,6 +131,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0", IRNode.SUB_V, ">0"})
|
||||
public long[] vectorMulSub() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -125,6 +143,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Logic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.XOR_V, ">0"})
|
||||
public long[] vectorNot() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -134,6 +154,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.AND_V, ">0"})
|
||||
public long[] vectorAnd() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -143,6 +165,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.OR_V, ">0"})
|
||||
public long[] vectorOr() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -152,6 +176,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.XOR_V, ">0"})
|
||||
public long[] vectorXor() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -162,6 +188,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Shift ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.LSHIFT_V, ">0"})
|
||||
public long[] vectorShiftLeft() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -171,6 +199,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.RSHIFT_V, ">0"})
|
||||
public long[] vectorSignedShiftRight() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -180,6 +210,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.URSHIFT_V, ">0"})
|
||||
public long[] vectorUnsignedShiftRight() {
|
||||
long[] res = new long[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -226,6 +258,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that long integer max produces non-vectorizable CMoveL node.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public long reductionMax() {
|
||||
long res = Long.MIN_VALUE;
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -235,6 +269,8 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that long integer min produces non-vectorizable CMoveL node.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public long reductionMin() {
|
||||
long res = Long.MAX_VALUE;
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -243,4 +279,3 @@ public class BasicLongOpTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,9 +40,11 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private short[] a;
|
||||
private short[] b;
|
||||
@ -64,6 +66,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Arithmetic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public short[] vectorNeg() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -73,6 +77,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "ssse3", "true"},
|
||||
counts = {IRNode.ABS_V, ">0"})
|
||||
public short[] vectorAbs() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -82,6 +88,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.ADD_V, ">0"})
|
||||
public short[] vectorAdd() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -91,6 +99,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public short[] vectorSub() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -100,6 +110,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public short[] vectorMul() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -109,6 +121,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0", IRNode.ADD_V, ">0"})
|
||||
public short[] vectorMulAdd() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -118,6 +132,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.MUL_V, ">0", IRNode.SUB_V, ">0"})
|
||||
public short[] vectorMulSub() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -128,6 +144,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Logic ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.XOR_V, ">0"})
|
||||
public short[] vectorNot() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -137,6 +155,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.AND_V, ">0"})
|
||||
public short[] vectorAnd() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -146,6 +166,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.OR_V, ">0"})
|
||||
public short[] vectorOr() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -155,6 +177,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.XOR_V, ">0"})
|
||||
public short[] vectorXor() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -165,6 +189,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Shift ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.LSHIFT_V, ">0"})
|
||||
public short[] vectorShiftLeft() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -174,6 +200,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.RSHIFT_V, ">0"})
|
||||
public short[] vectorSignedShiftRight() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -183,6 +211,33 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that min operations on subword types cannot be vectorized
|
||||
// because higher bits will be lost.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public short[] vectorMin() {
|
||||
short[] res = new short[SIZE];
|
||||
int val = 65536;
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
res[i] = (short) Math.min(a[i], val);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that max operations on subword types cannot be vectorized
|
||||
// because higher bits will be lost.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public short[] vectorMax() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
res[i] = (short) Math.max(a[i], b[i]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.RSHIFT_V, ">0"})
|
||||
public short[] vectorUnsignedShiftRight() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -193,6 +248,8 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
|
||||
// ------------- ReverseBytes -------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx2", "true"},
|
||||
counts = {IRNode.REVERSE_BYTES_V, ">0"})
|
||||
public short[] reverseBytesWithShort() {
|
||||
short[] res = new short[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -202,6 +259,9 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that reverseBytes cannot be vectorized if the vector element
|
||||
// type doesn't match the caller's class type.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public int[] reverseBytesWithInt() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -210,4 +270,3 @@ public class BasicShortOpTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,11 +40,13 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private int[] ints;
|
||||
private short[] shorts;
|
||||
@ -75,6 +77,10 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Linear Indexes ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.ADD_VI, ">0"})
|
||||
public int[] indexPlusConstant() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE / 2; i++) {
|
||||
@ -84,6 +90,10 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "sse4_1", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public int[] indexMinusConstant() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = SIZE / 2; i < SIZE; i++) {
|
||||
@ -93,6 +103,10 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse4_1", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public int[] indexPlusInvariant() {
|
||||
int[] res = new int[SIZE];
|
||||
System.arraycopy(ints, 0, res, 0, SIZE);
|
||||
@ -103,6 +117,10 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "sse4_1", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public int[] indexMinusInvariant() {
|
||||
int[] res = new int[SIZE];
|
||||
System.arraycopy(ints, 0, res, 0, SIZE);
|
||||
@ -113,6 +131,10 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse4_1", "true"},
|
||||
counts = {IRNode.MUL_V, ">0"})
|
||||
public int[] indexWithInvariantAndConstant() {
|
||||
int[] res = new int[SIZE];
|
||||
System.arraycopy(ints, 0, res, 0, SIZE);
|
||||
@ -123,6 +145,10 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.SUB_V, ">0"})
|
||||
public int[] indexWithTwoInvariants() {
|
||||
int[] res = new int[SIZE];
|
||||
System.arraycopy(ints, 0, res, 0, SIZE);
|
||||
@ -133,7 +159,8 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that this case cannot be vectorized due to data dependence
|
||||
// Note that this case cannot be vectorized due to data dependence.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public int[] indexWithDifferentConstants() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE / 4; i++) {
|
||||
@ -143,7 +170,8 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that this case cannot be vectorized due to data dependence
|
||||
// Note that this case cannot be vectorized due to data dependence.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public int[] indexWithDifferentInvariants() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = SIZE / 4; i < SIZE / 2; i++) {
|
||||
@ -204,8 +232,8 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that this case cannot be vectorized due to data dependence
|
||||
// between src and dest of the assignment.
|
||||
// Note that this case cannot be vectorized due to data dependence.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public int[] sameArrayWithDifferentIndex() {
|
||||
int[] res = new int[SIZE];
|
||||
System.arraycopy(ints, 0, res, 0, SIZE);
|
||||
@ -217,7 +245,8 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Subword Type Arrays ----------------
|
||||
@Test
|
||||
// Note that this case cannot be vectorized due to data dependence
|
||||
// Note that this case cannot be vectorized due to data dependence.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public short[] shortArrayWithDependence() {
|
||||
short[] res = new short[SIZE];
|
||||
System.arraycopy(shorts, 0, res, 0, SIZE);
|
||||
@ -228,7 +257,8 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that this case cannot be vectorized due to data dependence
|
||||
// Note that this case cannot be vectorized due to data dependence.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public char[] charArrayWithDependence() {
|
||||
char[] res = new char[SIZE];
|
||||
System.arraycopy(chars, 0, res, 0, SIZE);
|
||||
@ -239,7 +269,8 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that this case cannot be vectorized due to data dependence
|
||||
// Note that this case cannot be vectorized due to data dependence.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public byte[] byteArrayWithDependence() {
|
||||
byte[] res = new byte[SIZE];
|
||||
System.arraycopy(bytes, 0, res, 0, SIZE);
|
||||
@ -250,7 +281,8 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that this case cannot be vectorized due to data dependence
|
||||
// Note that this case cannot be vectorized due to data dependence.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public boolean[] booleanArrayWithDependence() {
|
||||
boolean[] res = new boolean[SIZE];
|
||||
System.arraycopy(booleans, 0, res, 0, SIZE);
|
||||
@ -262,6 +294,8 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------------- Multiple Operations ----------------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] differentIndexWithDifferentTypes() {
|
||||
int[] res1 = new int[SIZE];
|
||||
short[] res2 = new short[SIZE];
|
||||
@ -273,7 +307,8 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that this case cannot be vectorized due to data dependence
|
||||
// Note that this case cannot be vectorized due to data dependence.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public int[] differentIndexWithSameType() {
|
||||
int[] res1 = new int[SIZE];
|
||||
int[] res2 = new int[SIZE];
|
||||
@ -284,4 +319,3 @@ public class LoopArrayIndexComputeTest extends VectorizationTestRunner {
|
||||
return res2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,11 +40,13 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private int[] a;
|
||||
private int[] b;
|
||||
@ -80,6 +82,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] opWithConstant() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -89,6 +93,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] opWithLoopInvariant() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -98,6 +104,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] opWithConstantAndLoopInvariant() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -107,6 +115,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] multipleOps() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -116,6 +126,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] multipleOpsWithMultipleConstants() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -125,6 +137,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] multipleStores() {
|
||||
int[] res1 = new int[SIZE];
|
||||
int[] res2 = new int[SIZE];
|
||||
@ -138,6 +152,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] multipleStoresWithCommonSubExpression() {
|
||||
int[] res1 = new int[SIZE];
|
||||
int[] res2 = new int[SIZE];
|
||||
@ -151,6 +167,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] multipleOpsWith2DifferentTypes() {
|
||||
short[] res1 = new short[SIZE];
|
||||
int[] res2 = new int[SIZE];
|
||||
@ -162,6 +180,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public long[] multipleOpsWith3DifferentTypes() {
|
||||
short[] res1 = new short[SIZE];
|
||||
int[] res2 = new int[SIZE];
|
||||
@ -175,6 +195,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public long[] multipleOpsWith2NonAdjacentTypes() {
|
||||
short[] res1 = new short[SIZE];
|
||||
long[] res2 = new long[SIZE];
|
||||
@ -186,6 +208,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] multipleOpsWith2DifferentTypesAndConstant() {
|
||||
short[] res1 = new short[SIZE];
|
||||
int[] res2 = new int[SIZE];
|
||||
@ -197,6 +221,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] multipleOpsWith2DifferentTypesAndInvariant() {
|
||||
short[] res1 = new short[SIZE];
|
||||
int[] res2 = new int[SIZE];
|
||||
@ -208,6 +234,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] multipleOpsWith2DifferentTypesAndComplexExpression() {
|
||||
short[] res1 = new short[SIZE];
|
||||
int[] res2 = new int[SIZE];
|
||||
@ -218,6 +246,20 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
return res2;
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] multipleOpsWith2DifferentTypesAndSharedOp() {
|
||||
int i = 0, sum = 0;
|
||||
int[] res1 = new int[SIZE];
|
||||
short[] res2 = new short[SIZE];
|
||||
while (++i < SIZE) {
|
||||
sum += (res1[i]--);
|
||||
res2[i]++;
|
||||
}
|
||||
return res1;
|
||||
}
|
||||
|
||||
@Test
|
||||
public int[] fillIndexPlusStride() {
|
||||
int[] res = new int[SIZE];
|
||||
@ -255,6 +297,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] manuallyUnrolledStride2() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE - 1; i += 2) {
|
||||
@ -265,6 +309,8 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int partialVectorizableLoop() {
|
||||
int[] res = new int[SIZE];
|
||||
int k = 9;
|
||||
@ -275,4 +321,3 @@ public class LoopCombinedOpTest extends VectorizationTestRunner {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,11 +40,13 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class LoopControlFlowTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private int[] a;
|
||||
private int[] b;
|
||||
@ -62,6 +64,8 @@ public class LoopControlFlowTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] loopInvariantCondition() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -86,5 +90,16 @@ public class LoopControlFlowTest extends VectorizationTestRunner {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that this loop cannot be vectorized due to early break.
|
||||
@IR(failOn = {IRNode.STORE_VECTOR})
|
||||
public int conditionalBreakReduction() {
|
||||
int sum = 0, i = 0;
|
||||
for (i = 0; i < SIZE; i++) {
|
||||
sum += i;
|
||||
if (invCond) break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,27 +40,35 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class LoopLiveOutNodesTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 3333;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private int[] a;
|
||||
private int start;
|
||||
private int limit;
|
||||
|
||||
// tmp[] may be modified and thus should not be returned in cases.
|
||||
private int[] tmp;
|
||||
|
||||
public LoopLiveOutNodesTest() {
|
||||
a = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
a[i] = -697989 * i;
|
||||
}
|
||||
tmp = new int[SIZE];
|
||||
Random ran = new Random(31415926);
|
||||
start = 999 + ran.nextInt() % 100;
|
||||
limit = start + 1357;
|
||||
start = ran.nextInt() % 100;
|
||||
limit = start + 235;
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int SimpleIvUsed() {
|
||||
int i = 0;
|
||||
int[] res = new int[SIZE];
|
||||
@ -71,6 +79,8 @@ public class LoopLiveOutNodesTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int indexedByIvUsed() {
|
||||
int i = 0;
|
||||
int[] res = new int[SIZE];
|
||||
@ -81,6 +91,8 @@ public class LoopLiveOutNodesTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int ivUsedMultiple() {
|
||||
int i = 0;
|
||||
int[] res = new int[SIZE];
|
||||
@ -91,6 +103,8 @@ public class LoopLiveOutNodesTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int ivUsedComplexExpr() {
|
||||
int i = 0;
|
||||
int[] res = new int[SIZE];
|
||||
@ -101,6 +115,8 @@ public class LoopLiveOutNodesTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] ivUsedAnotherLoop() {
|
||||
int i = 0;
|
||||
int[] res = new int[SIZE];
|
||||
@ -108,7 +124,7 @@ public class LoopLiveOutNodesTest extends VectorizationTestRunner {
|
||||
res[i] = a[i] * 100;
|
||||
}
|
||||
for (int j = i; j < i + 55; j++) {
|
||||
res[j] = a[j - 500] + 2323;
|
||||
res[j] = a[j] + 2323;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -133,5 +149,15 @@ public class LoopLiveOutNodesTest extends VectorizationTestRunner {
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public int nestedLoopIndexLiveOut() {
|
||||
int k = 0;
|
||||
for (int i = 0; i < 50; i += 2) {
|
||||
for (int j = 0; j < 10; j++) {
|
||||
tmp[k++] = 5;
|
||||
}
|
||||
}
|
||||
return k;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,11 +40,13 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class LoopRangeStrideTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private int[] a;
|
||||
private int[] b;
|
||||
@ -60,8 +62,8 @@ public class LoopRangeStrideTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
Random ran = new Random(0);
|
||||
start = Math.abs(ran.nextInt() % 1000);
|
||||
end = start + 1315;
|
||||
start = Math.abs(ran.nextInt() % 100);
|
||||
end = start + 315;
|
||||
}
|
||||
|
||||
// ---------------- Range ----------------
|
||||
@ -75,6 +77,8 @@ public class LoopRangeStrideTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] nonConstantRange() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = start; i < end; i++) {
|
||||
@ -84,6 +88,8 @@ public class LoopRangeStrideTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] crossZeroRange() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = -20; i < 20; i++) {
|
||||
@ -93,6 +99,8 @@ public class LoopRangeStrideTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] nonEqualTestRange() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = start; i != end; i++) {
|
||||
@ -102,15 +110,19 @@ public class LoopRangeStrideTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] shortInductionLoop() {
|
||||
int[] res = new int[SIZE];
|
||||
for (short s = 123; s < 789; s++) {
|
||||
for (short s = 123; s < 456; s++) {
|
||||
res[s] = a[s] * b[s];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] whileLoop() {
|
||||
int[] res = new int[SIZE];
|
||||
int i = start;
|
||||
@ -122,6 +134,8 @@ public class LoopRangeStrideTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] doWhileLoop() {
|
||||
int[] res = new int[SIZE];
|
||||
int i = start;
|
||||
@ -160,8 +174,9 @@ public class LoopRangeStrideTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] countDownLoop() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = SIZE - 1; i > 0; i--) {
|
||||
@ -181,6 +196,8 @@ public class LoopRangeStrideTest extends VectorizationTestRunner {
|
||||
|
||||
// ---------- Stride with scale ----------
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] countupLoopWithNegScale() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = SIZE / 2; i < SIZE; i++) {
|
||||
@ -190,6 +207,8 @@ public class LoopRangeStrideTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] countDownLoopWithNegScale() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = SIZE / 2; i > 0; i--) {
|
||||
@ -198,4 +217,3 @@ public class LoopRangeStrideTest extends VectorizationTestRunner {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -36,15 +36,18 @@
|
||||
* compiler.vectorization.runner.LoopReductionOpTest
|
||||
*
|
||||
* @requires vm.compiler2.enabled & vm.flagless
|
||||
*
|
||||
*/
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class LoopReductionOpTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private int[] a;
|
||||
private int[] b;
|
||||
@ -74,6 +77,10 @@ public class LoopReductionOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.LOAD_VECTOR, ">0"})
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.ADD_REDUCTION_V, ">0"})
|
||||
public int reductionAddSumOfArray() {
|
||||
int res = 0;
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -92,8 +99,8 @@ public class LoopReductionOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
// Note that adding constant in loop would be directly optimized to
|
||||
// scalar operations, hence this case is not vectorized.
|
||||
// Note that this loop should be optimized to straight-line code.
|
||||
@IR(failOn = {IRNode.COUNTED_LOOP})
|
||||
public int reductionAddConstant() {
|
||||
int res = 0;
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -112,6 +119,10 @@ public class LoopReductionOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "sse2", "true"},
|
||||
counts = {IRNode.LOAD_VECTOR, ">0"})
|
||||
@IR(applyIfCPUFeatureOr = {"sve", "true", "sse2", "true"},
|
||||
counts = {IRNode.ADD_REDUCTION_V, ">0"})
|
||||
public int reductionAddSumOfMultiple() {
|
||||
int res = 0;
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -165,6 +176,10 @@ public class LoopReductionOpTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
@IR(applyIfCPUFeatureOr = {"sse2", "true"},
|
||||
counts = {IRNode.ADD_REDUCTION_V, ">0"})
|
||||
public long reductionWithNonReductionDifferentSizes() {
|
||||
long res = 0L;
|
||||
int[] arr = new int[SIZE];
|
||||
@ -186,4 +201,3 @@ public class LoopReductionOpTest extends VectorizationTestRunner {
|
||||
return intSum + 2 * longSum;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,6 +40,8 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
public class MultipleLoopsTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 543;
|
||||
@ -60,6 +62,8 @@ public class MultipleLoopsTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] consecutiveLoops() {
|
||||
int[] res1 = new int[SIZE];
|
||||
int[] res2 = new int[SIZE];
|
||||
@ -77,6 +81,8 @@ public class MultipleLoopsTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] consecutiveLoopsNested() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int outer = 0; outer < 30; outer++) {
|
||||
@ -91,6 +97,8 @@ public class MultipleLoopsTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] nestedLoopOuterNonCounted() {
|
||||
int i = 1;
|
||||
int[] res = new int[SIZE];
|
||||
@ -105,6 +113,8 @@ public class MultipleLoopsTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] nestedLoopIndexCompute() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 50; i < 100; i++) {
|
||||
@ -114,5 +124,25 @@ public class MultipleLoopsTest extends VectorizationTestRunner {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public float reductionLoopWithAnotherReductionInput() {
|
||||
float res = 0.0F;
|
||||
int N = 400;
|
||||
int[] arr = new int[N];
|
||||
int i1 = 0, i2 = 0, i3, i4;
|
||||
for (int j = 0; j < N; ++j) {
|
||||
for (i3 = 1; i3 < 63; ++i3) {
|
||||
arr[i3] -= 1;
|
||||
i1 += i3;
|
||||
}
|
||||
for (i4 = 2; i4 < 63; ++i4) {
|
||||
res += i4 - i2;
|
||||
i2 = i1;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -41,11 +41,13 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class StripMinedLoopTest extends VectorizationTestRunner {
|
||||
|
||||
private static final int SIZE = 2345;
|
||||
private static final int SIZE = 543;
|
||||
|
||||
private int[] a = new int[SIZE];
|
||||
private int[] b = new int[SIZE];
|
||||
@ -58,6 +60,8 @@ public class StripMinedLoopTest extends VectorizationTestRunner {
|
||||
}
|
||||
|
||||
@Test
|
||||
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
|
||||
counts = {IRNode.STORE_VECTOR, ">0"})
|
||||
public int[] stripMinedVectorLoop() {
|
||||
int[] res = new int[SIZE];
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
@ -74,5 +78,19 @@ public class StripMinedLoopTest extends VectorizationTestRunner {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public int stripMinedOneIterationLoop() {
|
||||
int[] res = new int[SIZE];
|
||||
int i1, i2, i3, i4 = 11937;
|
||||
for (i1 = 1; i1 < SIZE; i1++) {
|
||||
for (i2 = 1; i2 < 2; i2++) {
|
||||
for (i3 = 1; i3 < 2; i3++) {
|
||||
i4 &= i3;
|
||||
}
|
||||
}
|
||||
res[i1] = 0;
|
||||
}
|
||||
return res[0] + i4;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Arm Limited. All rights reserved.
|
||||
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,6 +23,8 @@
|
||||
|
||||
package compiler.vectorization.runner;
|
||||
|
||||
import compiler.lib.ir_framework.*;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -34,6 +36,7 @@ import java.lang.reflect.Modifier;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
import jdk.test.whitebox.WhiteBox;
|
||||
@ -50,21 +53,17 @@ public class VectorizationTestRunner {
|
||||
|
||||
private static final long COMP_THRES_SECONDS = 30;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
protected @interface Test {}
|
||||
|
||||
protected void run() {
|
||||
// Add extra VM options to enable post loop vectorization
|
||||
WB.setBooleanVMFlag("UnlockExperimentalVMOptions", true);
|
||||
WB.setBooleanVMFlag("PostLoopMultiversioning", true);
|
||||
|
||||
// 1) Vectorization correctness test
|
||||
// For each method annotated with @Test in the test method, this test runner
|
||||
// invokes it twice - first time in the interpreter and second time compiled
|
||||
// by C2. Then this runner compares the two return values. Hence we require
|
||||
// each test method returning a primitive value or an array of primitive type.
|
||||
// And each test method should not throw any exceptions.
|
||||
Class klass = getClass();
|
||||
// Add extra VM options to verify experimental auto-vectorization
|
||||
WB.setBooleanVMFlag("UnlockExperimentalVMOptions", true);
|
||||
WB.setBooleanVMFlag("PostLoopMultiversioning", true);
|
||||
for (Method method : klass.getDeclaredMethods()) {
|
||||
try {
|
||||
if (method.isAnnotationPresent(Test.class)) {
|
||||
@ -76,6 +75,14 @@ public class VectorizationTestRunner {
|
||||
"." + method.getName() + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Vectorization ability test
|
||||
// To test vectorizability, invoke the IR test framework to check existence of
|
||||
// expected C2 IR node.
|
||||
TestFramework irTest = new TestFramework(klass);
|
||||
// Add extra VM options to enable more auto-vectorization chances
|
||||
irTest.addFlags("-XX:-OptimizeFill");
|
||||
irTest.start();
|
||||
}
|
||||
|
||||
private void verifyTestMethod(Method method) {
|
||||
@ -204,4 +211,3 @@ public class VectorizationTestRunner {
|
||||
testObj.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user