weiguozhi wrote: @bojle thank you for sharing your performance data. So we have following different performance data from different people. * spec cpu 2006 on x86 * spec cpu 2017 on x86 * spec cpu 2017 on AArch64 All have positive overall result.
As for the optimal scale number, we can see from all the testing, it's difficult to get a universal optimal scale number, even for a single test suite on a single cpu. It doesn't surprise me that individual functions may need different optimal scale number. The underlying reason is the CSR optimization actually has a trade off between * spill or split a potential CSR usage in cold basic blocks to reduce the prologue/epilogue cost. * pay the prologue/epilogue cost and use a CSR by two or more variables. So an optimal CSR optimization can only be accomplished after register allocation, and rescan each CSR usage, compare the prologue/epilogue cost with the spill/split cost of all variables that use the same CSR, then decide if need to spill/split those variables according to the compare result. In this case we don't need the scale number. But we actually allocate physical register to variables one by one, and need to decide if use a CSR or spill/split it at that time. So we don't know if a CSR can be used by two or more variables in an optimal allocation. And the scale number(and the previous CSRFirstTimeCost) is introduced to set higher threshold(lower CSRCost) for the optimization, so even if the CSR can be used by another variable, it doesn't hurt too much if another variable is not too hot. On the other hand, if multiple variables can be optimally allocated to the same CSR, then the first variable that should be assigned to the CSR but actually spilled is purely negative optimization. So I don't know a good method to find the optimal scale number systematically. Maybe a hopeful and fancy method to find the optimal scale number is use machine learning https://llvm.org/docs/MLGO.html, @mtrofin is expert in this area. Then we can train a model to find different scale number(or CSRCost) for different applications or functions. But I think this is a future project. https://github.com/llvm/llvm-project/pull/188609 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
