Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8327209 C2 MemorySegment: missing RCE and vectorization
  3. JDK-8356176

C2 MemorySegment: missing RCE with byteSize() in Loop Exit Check inside the for Expression

XMLWordPrintable

    • Cause Known

      In simple Memory Segment loops C2 fails to vectorize the loop if the loop exit check is MemorySegment::byteSize() and the function is called inside the for expression. If the function call is lifted above the for expression in the source code, everything works as expected.

      The reason for the missing vectorization seems to be that the range checks are not eliminated if the loop exit check in the for expression contains MemorySegment::byteSize() because it takes longer for the loop to be converted to a counted loop

      See the attached test case contributed by [~epeter]. Run it with
       java -Xbatch -XX:CompileCommand=compileonly,TestLoop.test\* -XX:CompileCommand=printcompilation,TestLoop.test\* -XX:+TraceNewVectors -XX:+TraceLoopOpts Test3.java

            mhaessig Manuel Hässig
            mhaessig Manuel Hässig
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: