Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8313720

C2 SuperWord: wrong result with -XX:+UseVectorCmov -XX:+UseCMoveUnconditionally

XMLWordPrintable

    • b11

        Found this while trying to find a reproducer for JDK-8313345.

        Reproduce:
        java -Xbatch -XX:CompileCommand=compileonly,Test2::test -XX:+TraceLoopOpts -XX:+UseVectorCmov -XX:+UseCMoveUnconditionally -XX:+TraceSuperWord -XX:+TraceNewVectors -XX:MaxVectorSize=64 Test2.java

        fail: 100 1.0 != 0.0 : 1.0 1.0
        Exception in thread "main" java.lang.RuntimeException: There were wrong results
        at Test2.verify(Test2.java:56)
        at Test2.main(Test2.java:44)

        I suspect the reason is the mixed comparison values in the Bool pack (le / lt):
        Pack: 11
         align: 0 1708 Bool === _ 1709 [[ 1707 ]] [le] !orig=1462,1241,163 !jvms: Test2::test @ bci:24 (line 16)
         align: 4 1702 Bool === _ 1703 [[ 1701 ]] [lt] !orig=1456,1235,255 !jvms: Test2::test @ bci:48 (line 17)
         align: 8 1696 Bool === _ 1697 [[ 1695 ]] [le] !orig=1450,163 !jvms: Test2::test @ bci:24 (line 16)
         align: 12 1690 Bool === _ 1691 [[ 1689 ]] [lt] !orig=1444,255 !jvms: Test2::test @ bci:48 (line 17)
         align: 16 1684 Bool === _ 1685 [[ 1683 ]] [le] !orig=1241,163 !jvms: Test2::test @ bci:24 (line 16)
         align: 20 1678 Bool === _ 1679 [[ 1677 ]] [lt] !orig=1235,255 !jvms: Test2::test @ bci:48 (line 17)
         align: 24 1666 Bool === _ 1667 [[ 1665 ]] [le] !orig=163 !jvms: Test2::test @ bci:24 (line 16)
         align: 28 1660 Bool === _ 1661 [[ 1659 ]] [lt] !orig=255 !jvms: Test2::test @ bci:48 (line 17)
         align: 32 1462 Bool === _ 1463 [[ 1461 ]] [le] !orig=1241,163 !jvms: Test2::test @ bci:24 (line 16)
         align: 36 1456 Bool === _ 1457 [[ 1455 ]] [lt] !orig=1235,255 !jvms: Test2::test @ bci:48 (line 17)
         align: 40 1450 Bool === _ 1451 [[ 1449 ]] [le] !orig=163 !jvms: Test2::test @ bci:24 (line 16)
         align: 44 1444 Bool === _ 1445 [[ 1443 ]] [lt] !orig=255 !jvms: Test2::test @ bci:48 (line 17)
         align: 48 1241 Bool === _ 1242 [[ 1240 ]] [le] !orig=163 !jvms: Test2::test @ bci:24 (line 16)
         align: 52 1235 Bool === _ 1236 [[ 1234 ]] [lt] !orig=255 !jvms: Test2::test @ bci:48 (line 17)
         align: 56 163 Bool === _ 162 [[ 317 ]] [le] !jvms: Test2::test @ bci:24 (line 16)
         align: 60 255 Bool === _ 254 [[ 318 ]] [lt] !jvms: Test2::test @ bci:48 (line 17)

        The logic I implemented in JDK-8306302 did not take account of hand unrolled loops, where the comparisons can be different.

              epeter Emanuel Peter
              epeter Emanuel Peter
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: