RFR: 8291809: Convert compiler/c2/cr7200264/TestSSE2IntVect.java to IR verification test [v2]
Daniel Lundén
dlunden at openjdk.org
Thu Jan 18 12:52:15 UTC 2024
On Thu, 18 Jan 2024 12:24:42 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> 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 comm...
Thanks for your investigation efforts @eme64!
> Ah, a general comment: we also care about aarch64, i,e, asimd. Not just about sse2 ;)
> Would it be reasonable to add asimd as well?
The original tests only specified sse as requirements, but I think it sounds reasonable to add asimd.
> 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?
Thanks for spotting this, I'll investigate a bit more. I simply ran the tests locally (`make test TEST="hotspot/jtreg/compiler/c2/cr7200264/TestIntVect.java"`) with unreasonable values for the `@IR` counts (e.g., `@IR(counts = { IRNode.LSHIFT_VI, ">= 10000" })`. In the test output, it then gave an error indicating that the actual number was 0. I'll check if I messed up somewhere.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17428#issuecomment-1898419886
More information about the hotspot-compiler-dev
mailing list