RFR: 8291809: Convert compiler/c2/cr7200264/TestSSE2IntVect.java to IR verification test [v2]

Emanuel Peter epeter at openjdk.org
Thu Jan 25 14:37:38 UTC 2024


On Wed, 24 Jan 2024 13:03:15 GMT, Daniel Lundén <dlunden at openjdk.org> wrote:

>> 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...
>
> Thanks @eme64. I've addressed all comments now; please have a look again.

@dlunde Given the findings here: https://github.com/openjdk/jdk/pull/17428#discussion_r1466460916
I think you should add a IR rule on every test.
And for the ones that do not currently vectorize, please add a negative IR rule, so that we can detect when that changes.
For example when we implement a feature, then we can properly fix up the IR rule.

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

PR Comment: https://git.openjdk.org/jdk/pull/17428#issuecomment-1910334886


More information about the hotspot-compiler-dev mailing list