Skip to content

Commit fe47075

Browse files
cost0muchVictor Rudometov
authored andcommitted
8309894: compiler/vectorapi/VectorLogicalOpIdentityTest.java fails on SVE system with UseSVE=0
Reviewed-by: phh Backport-of: 60544f9088c11e4718a9cd77f21792c6ba387440
1 parent 4f28612 commit fe47075

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

test/hotspot/jtreg/compiler/lib/ir_framework/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ One might also want to restrict the application of certain `@IR` rules depending
124124
- `applyIfOr`: Only apply a rule if **at least one** flag has the specified value/range of values.
125125

126126
#### Disable/Enable IR Rules based on available CPU Features
127-
Sometimes, an `@IR` rule should only be applied if a certain CPU feature is present. This can be done with
128-
the attributes `applyIfCPUFeatureXXX` in [@IR](./IR.java) which follow the same logic as the `applyIfXXX` methods for flags in the previous section. If a `@Test` annotated method has multiple preconditions (for example `applyIf` and `applyIfCPUFeature`), they are evaluated as a logical conjunction. An example with `applyIfCPUFeatureXXX` can be found in [TestCPUFeatureCheck](../../../testlibrary_tests/ir_framework/tests/TestCPUFeatureCheck.java) (internal framework test).
127+
Sometimes, an `@IR` rule should only be applied if a certain CPU feature is present. This can be done with the attributes `applyIfCPUFeatureXXX` in [@IR](./IR.java) which follow the same logic as the `applyIfXXX` methods for flags in the previous section. An example with `applyIfCPUFeatureXXX` can be found in [TestCPUFeatureCheck](../../../testlibrary_tests/ir_framework/tests/TestCPUFeatureCheck.java) (internal framework test).
128+
129+
If a `@Test` annotated method has multiple preconditions (for example `applyIf` and `applyIfCPUFeature`), they are evaluated as a logical conjunction. It's worth noting that flags in `applyIf` are checked only if the CPU features in `applyIfCPUFeature` are matched when they are both specified. This avoids the VM flag being evaluated on hardware that does not support it. An example with both `applyIfCPUFeatureXXX` and `applyIfXXX` can be found in [TestPreconditions](../../../testlibrary_tests/ir_framework/tests/TestPreconditions.java) (internal framework test).
129130

130131
#### Implicitly Skipping IR Verification
131132
An IR verification cannot always be performed. Certain VM flags explicitly disable IR verification, change the IR shape in unexpected ways letting IR rules fail or even make IR verification impossible:

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ private boolean shouldApplyIrRule(IR irAnno, String m, int ruleIndex, int ruleMa
134134
checkIRAnnotations(irAnno);
135135
if (isIRNodeUnsupported(irAnno)) {
136136
return false;
137+
} else if (irAnno.applyIfCPUFeature().length != 0 && !hasAllRequiredCPUFeature(irAnno.applyIfCPUFeature())) {
138+
printDisableReason(m, "Feature constraint not met (applyIfCPUFeature)", irAnno.applyIfCPUFeature(), ruleIndex, ruleMax);
139+
return false;
140+
} else if (irAnno.applyIfCPUFeatureAnd().length != 0 && !hasAllRequiredCPUFeature(irAnno.applyIfCPUFeatureAnd())) {
141+
printDisableReason(m, "Not all feature constraints are met (applyIfCPUFeatureAnd)", irAnno.applyIfCPUFeatureAnd(), ruleIndex, ruleMax);
142+
return false;
143+
} else if (irAnno.applyIfCPUFeatureOr().length != 0 && !hasAnyRequiredCPUFeature(irAnno.applyIfCPUFeatureOr())) {
144+
printDisableReason(m, "None of the feature constraints met (applyIfCPUFeatureOr)", irAnno.applyIfCPUFeatureOr(), ruleIndex, ruleMax);
145+
return false;
137146
} else if (irAnno.applyIf().length != 0 && !hasAllRequiredFlags(irAnno.applyIf(), "applyIf")) {
138147
printDisableReason(m, "Flag constraint not met (applyIf)", irAnno.applyIf(), ruleIndex, ruleMax);
139148
return false;
@@ -146,15 +155,6 @@ private boolean shouldApplyIrRule(IR irAnno, String m, int ruleIndex, int ruleMa
146155
} else if (irAnno.applyIfOr().length != 0 && hasNoRequiredFlags(irAnno.applyIfOr(), "applyIfOr")) {
147156
printDisableReason(m, "None of the flag constraints met (applyIfOr)", irAnno.applyIfOr(), ruleIndex, ruleMax);
148157
return false;
149-
} else if (irAnno.applyIfCPUFeature().length != 0 && !hasAllRequiredCPUFeature(irAnno.applyIfCPUFeature())) {
150-
printDisableReason(m, "Feature constraint not met (applyIfCPUFeature)", irAnno.applyIfCPUFeature(), ruleIndex, ruleMax);
151-
return false;
152-
} else if (irAnno.applyIfCPUFeatureAnd().length != 0 && !hasAllRequiredCPUFeature(irAnno.applyIfCPUFeatureAnd())) {
153-
printDisableReason(m, "Not all feature constraints are met (applyIfCPUFeatureAnd)", irAnno.applyIfCPUFeatureAnd(), ruleIndex, ruleMax);
154-
return false;
155-
} else if (irAnno.applyIfCPUFeatureOr().length != 0 && !hasAnyRequiredCPUFeature(irAnno.applyIfCPUFeatureOr())) {
156-
printDisableReason(m, "None of the feature constraints met (applyIfCPUFeatureOr)", irAnno.applyIfCPUFeatureOr(), ruleIndex, ruleMax);
157-
return false;
158158
} else {
159159
// All preconditions satisfied: apply rule.
160160
return true;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, Arm Limited. All rights reserved.
2+
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
33
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,29 @@ public static void testApplyIfCPUFeatureOnly() {}
5656
@IR(applyIfCPUFeatureAnd = {"asimd", "true", "sse", "true"},
5757
applyIf = {"LoopMaxUnroll", "= 8"},
5858
counts = {IRNode.LOOP, ">= 1000"})
59-
public static void testApplyBoth() {}
59+
public static void testApplyBoth1() {}
6060

61+
// The IR check should not be applied on aarch64, because the "applyIfAnd"
62+
// condition returns false as the VM is run with LoopMaxUnroll=8.
63+
// Note that precondition `applyIfCPUFeature` will be evaluated first with
64+
// early return. Hence the IR check should not be applied on non-aarch64
65+
// systems, and no exception is thrown because we are not checking the value
66+
// of the unsupported "UseSVE" flag on non-aarch64 systems.
67+
@Test
68+
@IR(applyIfCPUFeature = {"asimd", "true"},
69+
applyIfAnd = {"UseSVE", "= 0", "LoopMaxUnroll", "= 0"},
70+
counts = {IRNode.LOOP, ">= 1000"})
71+
public static void testApplyBoth2() {}
72+
73+
// The IR check should not be applied on x86, because the "applyIfAnd"
74+
// condition returns false as the VM is run with LoopMaxUnroll=8.
75+
// Note that precondition `applyIfCPUFeature` will be evaluated first with
76+
// early return. Hence the IR check should not be applied on non-avx systems,
77+
// and no exception is thrown because we are not checking the value of the
78+
// unsupported "UseAVX" flag on non-avx systems.
79+
@Test
80+
@IR(applyIfCPUFeature = {"avx", "true"},
81+
applyIfAnd = {"UseAVX", "= 2", "LoopMaxUnroll", "= 0"},
82+
counts = {IRNode.LOOP, ">= 1000"})
83+
public static void testApplyBoth3() {}
6184
}

0 commit comments

Comments
 (0)