Skip to content

Commit 8545e13

Browse files
author
Hamlin Li
committed
8356642: RISC-V: enable hotspot/jtreg/compiler/vectorapi/VectorFusedMultiplyAddSubTest.java
Reviewed-by: fyang, fjiang, mhaessig
1 parent ab8c808 commit 8545e13

File tree

2 files changed

+57
-23
lines changed

2 files changed

+57
-23
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,21 +2466,41 @@ public class IRNode {
24662466
machOnlyNameRegex(VFMSB_MASKED, "vfmsb_masked");
24672467
}
24682468

2469+
public static final String RISCV_VFNMSUB_MASKED = PREFIX + "RISCV_VFNMSUB_MASKED" + POSTFIX;
2470+
static {
2471+
machOnlyNameRegex(RISCV_VFNMSUB_MASKED, "vfnmsub_masked");
2472+
}
2473+
24692474
public static final String VFNMAD_MASKED = PREFIX + "VFNMAD_MASKED" + POSTFIX;
24702475
static {
24712476
machOnlyNameRegex(VFNMAD_MASKED, "vfnmad_masked");
24722477
}
24732478

2479+
public static final String RISCV_VFNMADD_MASKED = PREFIX + "RISCV_VFNMADD_MASKED" + POSTFIX;
2480+
static {
2481+
machOnlyNameRegex(RISCV_VFNMADD_MASKED, "vfnmadd_masked");
2482+
}
2483+
24742484
public static final String VFNMSB_MASKED = PREFIX + "VFNMSB_MASKED" + POSTFIX;
24752485
static {
24762486
machOnlyNameRegex(VFNMSB_MASKED, "vfnmsb_masked");
24772487
}
24782488

2489+
public static final String RISCV_VFMSUB_MASKED = PREFIX + "RISCV_VFMSUB_MASKED" + POSTFIX;
2490+
static {
2491+
machOnlyNameRegex(RISCV_VFMSUB_MASKED, "vfmsub_masked");
2492+
}
2493+
24792494
public static final String VFMAD_MASKED = PREFIX + "VFMAD_MASKED" + POSTFIX;
24802495
static {
24812496
machOnlyNameRegex(VFMAD_MASKED, "vfmad_masked");
24822497
}
24832498

2499+
public static final String RISCV_VFMADD_MASKED = PREFIX + "RISCV_VFMADD_MASKED" + POSTFIX;
2500+
static {
2501+
machOnlyNameRegex(RISCV_VFMADD_MASKED, "vfmadd_masked");
2502+
}
2503+
24842504
public static final String VMASK_AND_NOT_L = PREFIX + "VMASK_AND_NOT_L" + POSTFIX;
24852505
static {
24862506
machOnlyNameRegex(VMASK_AND_NOT_L, "vmask_and_notL");

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

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
3+
* Copyright (c) 2025, Rivos Inc. All rights reserved.
34
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45
*
56
* This code is free software; you can redistribute it and/or modify it
@@ -38,15 +39,16 @@
3839
import jdk.incubator.vector.VectorSpecies;
3940

4041
import jdk.test.lib.Asserts;
42+
import jdk.test.lib.Platform;
4143
import jdk.test.lib.Utils;
4244

4345
/**
4446
* @test
4547
* @bug 8282431
4648
* @key randomness
4749
* @library /test/lib /
48-
* @requires vm.cpu.features ~= ".*sve.*"
49-
* @summary AArch64: Add optimized rules for masked vector multiply-add/sub for SVE
50+
* @requires vm.cpu.features ~= ".*sve.*" | vm.cpu.features ~= ".*rvv.*"
51+
* @summary Add optimized rules for masked vector multiply-add/sub for SVE and RVV
5052
* @modules jdk.incubator.vector
5153
*
5254
* @run driver compiler.vectorapi.VectorFusedMultiplyAddSubTest
@@ -244,7 +246,7 @@ private static void assertArrayEqualsNeg(double[] r, double[] a, double[] b, dou
244246
}
245247

246248
@Test
247-
@IR(counts = { IRNode.VMLA_MASKED, ">= 1" })
249+
@IR(applyIfPlatformOr = {"aarch64", "true", "riscv64", "true"}, counts = { IRNode.VMLA_MASKED, ">= 1" })
248250
public static void testByteMultiplyAddMasked() {
249251
VectorMask<Byte> mask = VectorMask.fromArray(B_SPECIES, m, 0);
250252
for (int i = 0; i < LENGTH; i += B_SPECIES.length()) {
@@ -257,7 +259,7 @@ public static void testByteMultiplyAddMasked() {
257259
}
258260

259261
@Test
260-
@IR(counts = { IRNode.VMLS_MASKED, ">= 1" })
262+
@IR(applyIfPlatformOr = {"aarch64", "true", "riscv64", "true"}, counts = { IRNode.VMLS_MASKED, ">= 1" })
261263
public static void testByteMultiplySubMasked() {
262264
VectorMask<Byte> mask = VectorMask.fromArray(B_SPECIES, m, 0);
263265
for (int i = 0; i < LENGTH; i += B_SPECIES.length()) {
@@ -270,7 +272,7 @@ public static void testByteMultiplySubMasked() {
270272
}
271273

272274
@Test
273-
@IR(counts = { IRNode.VMLA_MASKED, ">= 1" })
275+
@IR(applyIfPlatformOr = {"aarch64", "true", "riscv64", "true"}, counts = { IRNode.VMLA_MASKED, ">= 1" })
274276
public static void testShortMultiplyAddMasked() {
275277
VectorMask<Short> mask = VectorMask.fromArray(S_SPECIES, m, 0);
276278
for (int i = 0; i < LENGTH; i += S_SPECIES.length()) {
@@ -283,7 +285,7 @@ public static void testShortMultiplyAddMasked() {
283285
}
284286

285287
@Test
286-
@IR(counts = { IRNode.VMLS_MASKED, ">= 1" })
288+
@IR(applyIfPlatformOr = {"aarch64", "true", "riscv64", "true"}, counts = { IRNode.VMLS_MASKED, ">= 1" })
287289
public static void testShortMultiplySubMasked() {
288290
VectorMask<Short> mask = VectorMask.fromArray(S_SPECIES, m, 0);
289291
for (int i = 0; i < LENGTH; i += S_SPECIES.length()) {
@@ -296,7 +298,7 @@ public static void testShortMultiplySubMasked() {
296298
}
297299

298300
@Test
299-
@IR(counts = { IRNode.VMLA_MASKED, ">= 1" })
301+
@IR(applyIfPlatformOr = {"aarch64", "true", "riscv64", "true"}, counts = { IRNode.VMLA_MASKED, ">= 1" })
300302
public static void testIntMultiplyAddMasked() {
301303
VectorMask<Integer> mask = VectorMask.fromArray(I_SPECIES, m, 0);
302304
for (int i = 0; i < LENGTH; i += I_SPECIES.length()) {
@@ -309,7 +311,7 @@ public static void testIntMultiplyAddMasked() {
309311
}
310312

311313
@Test
312-
@IR(counts = { IRNode.VMLS_MASKED, ">= 1" })
314+
@IR(applyIfPlatformOr = {"aarch64", "true", "riscv64", "true"}, counts = { IRNode.VMLS_MASKED, ">= 1" })
313315
public static void testIntMultiplySubMasked() {
314316
VectorMask<Integer> mask = VectorMask.fromArray(I_SPECIES, m, 0);
315317
for (int i = 0; i < LENGTH; i += I_SPECIES.length()) {
@@ -322,7 +324,7 @@ public static void testIntMultiplySubMasked() {
322324
}
323325

324326
@Test
325-
@IR(counts = { IRNode.VMLA_MASKED, ">= 1" })
327+
@IR(applyIfPlatformOr = {"aarch64", "true", "riscv64", "true"}, counts = { IRNode.VMLA_MASKED, ">= 1" })
326328
public static void testLongMultiplyAddMasked() {
327329
VectorMask<Long> mask = VectorMask.fromArray(L_SPECIES, m, 0);
328330
for (int i = 0; i < LENGTH; i += L_SPECIES.length()) {
@@ -335,7 +337,7 @@ public static void testLongMultiplyAddMasked() {
335337
}
336338

337339
@Test
338-
@IR(counts = { IRNode.VMLS_MASKED, ">= 1" })
340+
@IR(applyIfPlatformOr = {"aarch64", "true", "riscv64", "true"}, counts = { IRNode.VMLS_MASKED, ">= 1" })
339341
public static void testLongMultiplySubMasked() {
340342
VectorMask<Long> mask = VectorMask.fromArray(L_SPECIES, m, 0);
341343
for (int i = 0; i < LENGTH; i += L_SPECIES.length()) {
@@ -348,7 +350,8 @@ public static void testLongMultiplySubMasked() {
348350
}
349351

350352
@Test
351-
@IR(counts = { IRNode.VFMSB_MASKED, ">= 1" })
353+
@IR(applyIfPlatform = {"aarch64", "true"}, counts = { IRNode.VFMSB_MASKED, ">= 1" })
354+
@IR(applyIfPlatform = {"riscv64", "true"}, counts = { IRNode.RISCV_VFNMSUB_MASKED, ">= 1" })
352355
public static void testFloatMultiplySubMasked() {
353356
VectorMask<Float> mask = VectorMask.fromArray(F_SPECIES, m, 0);
354357
for (int i = 0; i < LENGTH; i += F_SPECIES.length()) {
@@ -361,7 +364,8 @@ public static void testFloatMultiplySubMasked() {
361364
}
362365

363366
@Test
364-
@IR(counts = { IRNode.VFMAD_MASKED, ">= 1" })
367+
@IR(applyIfPlatform = {"aarch64", "true"}, counts = { IRNode.VFMAD_MASKED, ">= 1" })
368+
@IR(applyIfPlatform = {"riscv64", "true"}, counts = { IRNode.RISCV_VFMADD_MASKED, ">= 1" })
365369
public static void testFloatMultiplyNegAMasked() {
366370
VectorMask<Float> mask = VectorMask.fromArray(F_SPECIES, m, 0);
367371
for (int i = 0; i < LENGTH; i += F_SPECIES.length()) {
@@ -374,7 +378,8 @@ public static void testFloatMultiplyNegAMasked() {
374378
}
375379

376380
@Test
377-
@IR(counts = { IRNode.VFNMAD_MASKED, ">= 1" })
381+
@IR(applyIfPlatform = {"aarch64", "true"}, counts = { IRNode.VFNMAD_MASKED, ">= 1" })
382+
@IR(applyIfPlatform = {"riscv64", "true"}, counts = { IRNode.RISCV_VFNMADD_MASKED, ">= 1" })
378383
public static void testFloatNegatedMultiplyAddMasked() {
379384
VectorMask<Float> mask = VectorMask.fromArray(F_SPECIES, m, 0);
380385
for (int i = 0; i < LENGTH; i += F_SPECIES.length()) {
@@ -387,7 +392,8 @@ public static void testFloatNegatedMultiplyAddMasked() {
387392
}
388393

389394
@Test
390-
@IR(counts = { IRNode.VFNMSB_MASKED, ">= 1" })
395+
@IR(applyIfPlatform = {"aarch64", "true"}, counts = { IRNode.VFNMSB_MASKED, ">= 1" })
396+
@IR(applyIfPlatform = {"riscv64", "true"}, counts = { IRNode.RISCV_VFMSUB_MASKED, ">= 1" })
391397
public static void testFloatNegatedMultiplyNegAMasked() {
392398
VectorMask<Float> mask = VectorMask.fromArray(F_SPECIES, m, 0);
393399
for (int i = 0; i < LENGTH; i += F_SPECIES.length()) {
@@ -400,7 +406,8 @@ public static void testFloatNegatedMultiplyNegAMasked() {
400406
}
401407

402408
@Test
403-
@IR(counts = { IRNode.VFNMSB_MASKED, ">= 1" })
409+
@IR(applyIfPlatform = {"aarch64", "true"}, counts = { IRNode.VFNMSB_MASKED, ">= 1" })
410+
@IR(applyIfPlatform = {"riscv64", "true"}, counts = { IRNode.RISCV_VFMSUB_MASKED, ">= 1" })
404411
public static void testFloatNegatedMultiplySubMasked() {
405412
VectorMask<Float> mask = VectorMask.fromArray(F_SPECIES, m, 0);
406413
for (int i = 0; i < LENGTH; i += F_SPECIES.length()) {
@@ -413,7 +420,8 @@ public static void testFloatNegatedMultiplySubMasked() {
413420
}
414421

415422
@Test
416-
@IR(counts = { IRNode.VFMSB_MASKED, ">= 1" })
423+
@IR(applyIfPlatform = {"aarch64", "true"}, counts = { IRNode.VFMSB_MASKED, ">= 1" })
424+
@IR(applyIfPlatform = {"riscv64", "true"}, counts = { IRNode.RISCV_VFNMSUB_MASKED, ">= 1" })
417425
public static void testDoubleMultiplySubMasked() {
418426
VectorMask<Double> mask = VectorMask.fromArray(D_SPECIES, m, 0);
419427
for (int i = 0; i < LENGTH; i += D_SPECIES.length()) {
@@ -426,7 +434,8 @@ public static void testDoubleMultiplySubMasked() {
426434
}
427435

428436
@Test
429-
@IR(counts = { IRNode.VFMAD_MASKED, ">= 1" })
437+
@IR(applyIfPlatform = {"aarch64", "true"}, counts = { IRNode.VFMAD_MASKED, ">= 1" })
438+
@IR(applyIfPlatform = {"riscv64", "true"}, counts = { IRNode.RISCV_VFMADD_MASKED, ">= 1" })
430439
public static void testDoubleMultiplyNegAMasked() {
431440
VectorMask<Double> mask = VectorMask.fromArray(D_SPECIES, m, 0);
432441
for (int i = 0; i < LENGTH; i += D_SPECIES.length()) {
@@ -439,7 +448,8 @@ public static void testDoubleMultiplyNegAMasked() {
439448
}
440449

441450
@Test
442-
@IR(counts = { IRNode.VFNMAD_MASKED, ">= 1" })
451+
@IR(applyIfPlatform = {"aarch64", "true"}, counts = { IRNode.VFNMAD_MASKED, ">= 1" })
452+
@IR(applyIfPlatform = {"riscv64", "true"}, counts = { IRNode.RISCV_VFNMADD_MASKED, ">= 1" })
443453
public static void testDoubleNegatedMultiplyAddMasked() {
444454
VectorMask<Double> mask = VectorMask.fromArray(D_SPECIES, m, 0);
445455
for (int i = 0; i < LENGTH; i += D_SPECIES.length()) {
@@ -452,7 +462,8 @@ public static void testDoubleNegatedMultiplyAddMasked() {
452462
}
453463

454464
@Test
455-
@IR(counts = { IRNode.VFNMSB_MASKED, ">= 1" })
465+
@IR(applyIfPlatform = {"aarch64", "true"}, counts = { IRNode.VFNMSB_MASKED, ">= 1" })
466+
@IR(applyIfPlatform = {"riscv64", "true"}, counts = { IRNode.RISCV_VFMSUB_MASKED, ">= 1" })
456467
public static void testDoubleNegatedMultiplyNegAMasked() {
457468
VectorMask<Double> mask = VectorMask.fromArray(D_SPECIES, m, 0);
458469
for (int i = 0; i < LENGTH; i += D_SPECIES.length()) {
@@ -465,7 +476,8 @@ public static void testDoubleNegatedMultiplyNegAMasked() {
465476
}
466477

467478
@Test
468-
@IR(counts = { IRNode.VFNMSB_MASKED, ">= 1" })
479+
@IR(applyIfPlatform = {"aarch64", "true"}, counts = { IRNode.VFNMSB_MASKED, ">= 1" })
480+
@IR(applyIfPlatform = {"riscv64", "true"}, counts = { IRNode.RISCV_VFMSUB_MASKED, ">= 1" })
469481
public static void testDoubleNegatedMultiplySubMasked() {
470482
VectorMask<Double> mask = VectorMask.fromArray(D_SPECIES, m, 0);
471483
for (int i = 0; i < LENGTH; i += D_SPECIES.length()) {
@@ -479,8 +491,10 @@ public static void testDoubleNegatedMultiplySubMasked() {
479491

480492
public static void main(String[] args) {
481493
TestFramework testFramework = new TestFramework();
482-
testFramework.setDefaultWarmup(5000)
483-
.addFlags("--add-modules=jdk.incubator.vector", "-XX:UseSVE=1")
484-
.start();
494+
testFramework.setDefaultWarmup(5000).addFlags("--add-modules=jdk.incubator.vector");
495+
if (Platform.isAArch64()) {
496+
testFramework.addFlags("-XX:UseSVE=1");
497+
}
498+
testFramework.start();
485499
}
486500
}

0 commit comments

Comments
 (0)