RFR: 8291809: Convert compiler/c2/cr7200264/TestSSE2IntVect.java to IR verification test [v2]
Emanuel Peter
epeter at openjdk.org
Thu Jan 18 12:27:15 UTC 2024
On Wed, 17 Jan 2024 10:03:06 GMT, Daniel Lundén <dlunden at openjdk.org> wrote:
>> This changeset translates the tests in `compiler/c2/cr7200264/` to use the IR verification framework.
>>
>> The proposed translation, to the extent possible, attempts to preserve the semantics of the original test. A major difference is that the IR checks are now local (for every `test_*` method) instead of global. The execution time of the new test is comparable to the old test.
>>
>> Testing:
>> - [GitHub Actions](https://github.com/dlunde/jdk/actions/runs/7553846710)
>> - Ran the new translated tests within all tier1 through tier10 contexts on windows-x64, linux-x64, linux-aarch64, macosx-x64, and macosx-aarch64.
>> - Tested that manually adding `-XX:LoopUnrollLimit=0` to the test framework flags caused the translated tests to fail. Note: it is, however, no longer possible to break the test by passing `-XX:LoopUnrollLimit=0` on the command line.
>
> Daniel Lundén has updated the pull request incrementally with one additional commit since the last revision:
>
> Refactor test to use multiple @Test
Well, I think at least some of the `shift` examples should also vectorize:
`./java -XX:CompileCommand=compileonly,Test::test1 -XX:+TraceSuperWord -XX:+TraceLoopOpts -XX:+TraceNewVectors -XX:UseAVX=2 Test.java`
Not sure if for all SSE and AVX levels, but all that I quickly checked with the UseSSE and USEAVX flags.
TraceNewVectors [SuperWord]: 832 LoadVector === 347 766 740 [[ 738 734 731 727 619 616 518 136 ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; mismatched #vectory[8]:{int} !orig=[739],[620],[519],[135] !jvms: Test::test2 @ bci:12 (line 21)
TraceNewVectors [SuperWord]: 836 LShiftVI === _ 832 835 [[ 736 733 730 725 618 615 516 157 ]] #vectory[8]:{int} !orig=[738],[619],[518],[136] !jvms: Test::test2 @ bci:14 (line 21)
TraceNewVectors [SuperWord]: 837 StoreVector === 763 766 737 836 [[ 341 766 160 339 ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; mismatched Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !orig=[736],[618],[516],[157],535 !jvms: Test::test2 @ bci:15 (line 21)
Test.java:
public class Test {
static int RANGE = 10_000;
public static void main(String[] args) {
int[] a = new int[RANGE];
int[] b = new int[RANGE];
for (int i = 0; i < 10_000; i++) {
test1(a, b);
test2(a, b, i % 200 - 100);
}
}
static void test1(int[] a, int[] b) {
for (int i = 0; i < a.length; i++) {
a[i] = (int)(b[i] << 32);
}
}
static void test2(int[] a, int[] b, int s) {
for (int i = 0; i < a.length; i++) {
a[i] = (int)(b[i] << s);
}
}
}
I also found this test in `test/hotspot/jtreg/compiler/vectorization/runner/BasicIntOpTest.java`:
@Test
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
counts = {IRNode.LSHIFT_VI, ">0"})
public int[] vectorShiftLeft() {
int[] res = new int[SIZE];
for (int i = 0; i < SIZE; i++) {
res[i] = a[i] << 3;
}
return res;
}
Plus, I see `test.addExpectedVectorization("LShiftVI", 5);` in `test/hotspot/jtreg/compiler/c2/cr7200264/TestSSE2IntVect.java`, which you now deleted.
@dlunde would you mind investigating a bit more if you can add some IR rules for all (or at least a few) of the shift examples?
If you think they really do not vectorize, can you paste me a Test.java with commandline how you run it?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17428#issuecomment-1898383407
More information about the hotspot-compiler-dev
mailing list