-
Sub-task
-
Resolution: Unresolved
-
P4
-
25
-
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
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