|
23 | 23 |
|
24 | 24 | /* |
25 | 25 | * @test |
26 | | - * @bug 8358521 |
| 26 | + * @bug 8358521 8385833 |
| 27 | + * @key randomness |
27 | 28 | * @summary Test reassociation of broadcasted inputs across vector operations |
28 | 29 | * @modules jdk.incubator.vector |
29 | 30 | * @library /test/lib / |
|
32 | 33 |
|
33 | 34 | package compiler.vectorapi; |
34 | 35 |
|
| 36 | +import compiler.lib.generators.Generator; |
| 37 | +import compiler.lib.generators.Generators; |
35 | 38 | import compiler.lib.ir_framework.*; |
| 39 | +import compiler.lib.verify.*; |
36 | 40 | import jdk.incubator.vector.*; |
37 | 41 | import java.util.stream.IntStream; |
38 | 42 |
|
@@ -602,4 +606,56 @@ static void test_byte_mul_reassociation_pattern4() { |
602 | 606 | ByteVector.broadcast(BSP, bb)) |
603 | 607 | .intoArray(byteOut, 0); |
604 | 608 | } |
| 609 | + |
| 610 | + private static final Generators RD = Generators.G; |
| 611 | + |
| 612 | + static int uA, uB, uC; |
| 613 | + |
| 614 | + static { |
| 615 | + Generator<Integer> ig = RD.ints(); |
| 616 | + uA = ig.next(); uB = ig.next(); uC = ig.next(); |
| 617 | + } |
| 618 | + |
| 619 | + static int[] umaxIntOut = new int[ISP.length()]; |
| 620 | + static int[] uminIntOut = new int[ISP.length()]; |
| 621 | + |
| 622 | + // UMAX(UMAX(bcast(uA), bcast(uB)), bcast(uC)). |
| 623 | + @Test |
| 624 | + @IR(counts = { IRNode.UMAX_VI, " >0 " }, |
| 625 | + applyIfCPUFeatureOr = {"avx", "true", "rvv", "true"}) |
| 626 | + @Warmup(value = 10000) |
| 627 | + static void test_int_umax_all_broadcast() { |
| 628 | + IntVector.broadcast(ISP, uA) |
| 629 | + .lanewise(VectorOperators.UMAX, uB) |
| 630 | + .lanewise(VectorOperators.UMAX, uC) |
| 631 | + .intoArray(umaxIntOut, 0); |
| 632 | + } |
| 633 | + |
| 634 | + @Check(test = "test_int_umax_all_broadcast") |
| 635 | + static void check_int_umax_all_broadcast() { |
| 636 | + int e = VectorMath.maxUnsigned(VectorMath.maxUnsigned(uA, uB), uC); |
| 637 | + for (int v : umaxIntOut) { |
| 638 | + Verify.checkEQ(v, e); |
| 639 | + } |
| 640 | + } |
| 641 | + |
| 642 | + // UMIN(UMIN(bcast(uA), bcast(uB)), bcast(uC)). |
| 643 | + @Test |
| 644 | + @IR(counts = { IRNode.UMIN_VI, " >0 " }, |
| 645 | + applyIfCPUFeatureOr = {"avx", "true", "rvv", "true"}) |
| 646 | + @Warmup(value = 10000) |
| 647 | + static void test_int_umin_all_broadcast() { |
| 648 | + IntVector.broadcast(ISP, uA) |
| 649 | + .lanewise(VectorOperators.UMIN, uB) |
| 650 | + .lanewise(VectorOperators.UMIN, uC) |
| 651 | + .intoArray(uminIntOut, 0); |
| 652 | + } |
| 653 | + |
| 654 | + @Check(test = "test_int_umin_all_broadcast") |
| 655 | + static void check_int_umin_all_broadcast() { |
| 656 | + int e = VectorMath.minUnsigned(VectorMath.minUnsigned(uA, uB), uC); |
| 657 | + for (int v : uminIntOut) { |
| 658 | + Verify.checkEQ(v, e); |
| 659 | + } |
| 660 | + } |
605 | 661 | } |
0 commit comments