Skip to content

Commit 1794f49

Browse files
committed
8302681: [IR Framework] Only allow cpuFeatures from a verified list
Reviewed-by: thartmann, pli, chagedorn, kvn
1 parent a43931b commit 1794f49

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

test/hotspot/jtreg/compiler/lib/ir_framework/test/IREncodingPrinter.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,31 @@ public class IREncodingPrinter {
5555
private Method method;
5656
private int ruleIndex;
5757

58+
// Please verify new CPU features before adding them. If we allow non-existent features
59+
// on this list, we will ignore tests and never execute them. Consult CPU_FEATURE_FLAGS
60+
// in corresponding vm_version_.hpp file to find correct cpu feature's name.
61+
private static final List<String> verifiedCPUFeatures = new ArrayList<String>( Arrays.asList(
62+
// x86
63+
"fma",
64+
// Intel SSE
65+
"sse",
66+
"sse2",
67+
"sse3",
68+
"ssse3",
69+
"sse4.1",
70+
// Intel AVX
71+
"avx",
72+
"avx2",
73+
"avx512",
74+
"avx512dq",
75+
"avx512vl",
76+
"avx512f",
77+
// AArch64
78+
"sha3",
79+
"asimd",
80+
"sve"
81+
));
82+
5883
public IREncodingPrinter() {
5984
output.append(START).append(System.lineSeparator());
6085
output.append("<method>,{comma separated applied @IR rule ids}").append(System.lineSeparator());
@@ -239,6 +264,11 @@ private boolean checkCPUFeature(String feature, String value) {
239264
return false;
240265
}
241266

267+
if (!verifiedCPUFeatures.contains(feature)) {
268+
TestFormat.failNoThrow("Provided CPU feature is not in verified list: " + feature + failAt());
269+
return false;
270+
}
271+
242272
boolean trueValue = value.contains("true");
243273
boolean falseValue = value.contains("false");
244274

test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public static void testAndSameValue4() {
302302
// Transform AndV(AndV(a, b, m), b, m) ==> AndV(a, b, m)
303303
@Test
304304
@Warmup(10000)
305-
@IR(counts = {IRNode.AND_V, "1"}, applyIfCPUFeatureOr = {"sve1", "true", "avx512", "true"})
305+
@IR(counts = {IRNode.AND_V, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
306306
public static void testAndMaskSameValue1() {
307307
VectorMask<Integer> mask = VectorMask.fromArray(I_SPECIES, m, 0);
308308
IntVector av = IntVector.fromArray(I_SPECIES, ia, 0);
@@ -323,7 +323,7 @@ public static void testAndMaskSameValue1() {
323323
// Transform AndV(AndV(a, b, m), a, m) ==> AndV(a, b, m)
324324
@Test
325325
@Warmup(10000)
326-
@IR(counts = {IRNode.AND_V, "1"}, applyIfCPUFeatureOr = {"sve1", "true", "avx512", "true"})
326+
@IR(counts = {IRNode.AND_V, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
327327
public static void testAndMaskSameValue2() {
328328
VectorMask<Long> mask = VectorMask.fromArray(L_SPECIES, m, 0);
329329
LongVector av = LongVector.fromArray(L_SPECIES, la, 0);
@@ -344,7 +344,7 @@ public static void testAndMaskSameValue2() {
344344
// Transform AndV(a, AndV(a, b, m), m) ==> AndV(a, b, m)
345345
@Test
346346
@Warmup(10000)
347-
@IR(counts = {IRNode.AND_V, "1"}, applyIfCPUFeatureOr = {"sve1", "true", "avx512", "true"})
347+
@IR(counts = {IRNode.AND_V, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
348348
public static void testAndMaskSameValue3() {
349349
VectorMask<Integer> mask = VectorMask.fromArray(I_SPECIES, m, 0);
350350
IntVector av = IntVector.fromArray(I_SPECIES, ia, 0);
@@ -566,7 +566,7 @@ public static void testOrSameValue4() {
566566
// Transform OrV(OrV(a, b, m), b, m) ==> OrV(a, b, m)
567567
@Test
568568
@Warmup(10000)
569-
@IR(counts = {IRNode.OR_V, "1"}, applyIfCPUFeatureOr = {"sve1", "true", "avx512", "true"})
569+
@IR(counts = {IRNode.OR_V, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
570570
public static void testOrMaskSameValue1() {
571571
VectorMask<Integer> mask = VectorMask.fromArray(I_SPECIES, m, 0);
572572
IntVector av = IntVector.fromArray(I_SPECIES, ia, 0);
@@ -587,7 +587,7 @@ public static void testOrMaskSameValue1() {
587587
// Transform OrV(OrV(a, b, m), a, m) ==> OrV(a, b, m)
588588
@Test
589589
@Warmup(10000)
590-
@IR(counts = {IRNode.OR_V, "1"}, applyIfCPUFeatureOr = {"sve1", "true", "avx512", "true"})
590+
@IR(counts = {IRNode.OR_V, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
591591
public static void testOrMaskSameValue2() {
592592
VectorMask<Long> mask = VectorMask.fromArray(L_SPECIES, m, 0);
593593
LongVector av = LongVector.fromArray(L_SPECIES, la, 0);
@@ -608,7 +608,7 @@ public static void testOrMaskSameValue2() {
608608
// Transform OrV(a, OrV(a, b, m), m) ==> OrV(a, b, m)
609609
@Test
610610
@Warmup(10000)
611-
@IR(counts = {IRNode.OR_V, "1"}, applyIfCPUFeatureOr = {"sve1", "true", "avx512", "true"})
611+
@IR(counts = {IRNode.OR_V, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
612612
public static void testOrMaskSameValue3() {
613613
VectorMask<Integer> mask = VectorMask.fromArray(I_SPECIES, m, 0);
614614
IntVector av = IntVector.fromArray(I_SPECIES, ia, 0);

test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPreconditions.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -45,15 +45,15 @@ public static void main(String[] args) {
4545
counts = {IRNode.LOOP, ">= 1000"})
4646
public static void testApplyIfOnly() {}
4747

48-
// The IR check should not be applied, since the CPU feature does not exist.
48+
// The IR check should not be applied, since asimd is aarch64 and sse intel.
4949
@Test
50-
@IR(applyIfCPUFeature = {"this-feature-does-not-exist-at-all", "true"},
50+
@IR(applyIfCPUFeatureAnd = {"asimd", "true", "sse", "true"},
5151
counts = {IRNode.LOOP, ">= 1000"})
5252
public static void testApplyIfCPUFeatureOnly() {}
5353

54-
// The IR check should not be applied, since the CPU feature does not exist.
54+
// The IR check should not be applied, since asimd is aarch64 and sse intel.
5555
@Test
56-
@IR(applyIfCPUFeature = {"this-feature-does-not-exist-at-all", "true"},
56+
@IR(applyIfCPUFeatureAnd = {"asimd", "true", "sse", "true"},
5757
applyIf = {"LoopMaxUnroll", "= 8"},
5858
counts = {IRNode.LOOP, ">= 1000"})
5959
public static void testApplyBoth() {}

0 commit comments

Comments
 (0)