gh-129987: Disable GCC SLP autovectorization for the interpreter loop on x86-64 #132295
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
#131750 mysteriously caused a ~6% regression for the free-threaded build. The cause was poor code generation of opcode dispatch in the interpreter loop. Before the change the dispatch code looked like:
After the change, the dispatch code looked like:
There are two problems:
Both of these problems appear to be caused by GCC's SLP autovectorizer. After the change, it decides to store both the
next_instrpointer and thestack_pointerin a single 128 bit register in the shared basic block that contains the opcode dispatch. This is introduced in theslp1pass (tree dump below):Disabling the SLP autovectorization pass for the interpreter loop fixes both problems. After this change the opcode dispatch code looks like:
Performance improves by ~8% for the free-threaded build.
Surprisingly, this also seems to improve performance for the default build by ~4%. I don't understand why and I don't fully trust the result. The generated dispatch code for the default build looks unaffected by this change. Additionally, measuring instructions retired using
fastbenchshows a negligible change, whereas it shows a ~8% reduction for the free-threaded build.DISPATCHcalls #129987