[llvm] Add a threshold to RegStackify to avoid register spills at runtime (PR #97283)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 2 03:49:05 PDT 2024
yolanda15 wrote:
Thanks all for the comments!
The issue I'm encoutering here is with V8 engine. It's not exactly related to stacks vs locals, but to make a deep stack, the RegStackify phase will also move instructions which breaks previous scheduling.
I attached an example showing the difference before and after RegStackify. You can find the last load (%24) used by the last madd will be moved to the first load after RegStackify.
[reg-stackify-dump.txt](https://github.com/user-attachments/files/16066680/reg-stackify-dump.txt)
During decoding, V8 will not change the original order of wasm bytecodes, values generated at the bottom of the stack is decoded firstly. Considering instruction scheduling is heavy at runtime and it is disabled by default in V8. I observed both Turbofan and Turboshaft optimizing compiler has such issue.
There might be one alternative solution though, that is to use the memory operand in the FMA instruction to reduce the register use. Unfortunately this is not enabled for WASM SIMD yet, I will have a try and see if it would help.
https://github.com/llvm/llvm-project/pull/97283
More information about the llvm-commits
mailing list