[jdk17] RFR: 8268293: VectorAPI cast operation on mask and shuffle is broken [v5]

Paul Sandoz psandoz at openjdk.java.net
Thu Jun 17 19:12:27 UTC 2021


On Thu, 17 Jun 2021 18:41:55 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> Existing implementation of VectoMask.cast and VectorShuffle.cast operation do not generate correct mask compliant with the species passed as the argument.
>> 
>> This patch fixes the implementation and adds the corresponding cast operation test cases to VectorAPI regression suite.
>
> Jatin Bhateja has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8268293: Review comments resolution.

test/jdk/jdk/incubator/vector/AbstractVectorConversionTest.java line 263:

> 261:                 }
> 262:             }
> 263:             args.add(new Object[]{src, sps});

Move the addition to `args` into the inner loop as:

  args.add(new Object[]{src, dst});


Then, change the signature of the tests to be `(VectorSpecies src, VectorSpecies> dst)`.

Then, we can add invocation loops around the cast operation from `src` -> `dst` in the legal case to trigger compilation.

For the illegal case your test would reduce to:

    @Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
    static void maskCastNeg(VectorSpecies src, List<VectorSpecies> dst) {
        long val = (1L << (src.length() & 63)) - 1L;
        VectorMask mask = VectorMask.fromLong(src, val);
        try {
            mask.cast(sps);
            Assert.fail();
        } catch (IllegalArgumentException e) {
        }
    }


And in fact i believe you can push the body of this method into a method on `AbstractVectorConversionTest`, further reducing duplication, such as:

    @Test(dataProvider = "fixedShapeXSegmentedIllegalCastSpecies")
    static void maskCastNeg(VectorSpecies src, List<VectorSpecies> dst) {
        maskCastFail(src, dest);
    }


Same technique can be applied to the non-exceptional test.

-------------

PR: https://git.openjdk.java.net/jdk17/pull/39


More information about the hotspot-compiler-dev mailing list