mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-08 17:00:18 +02:00
Many flag-generating instructions like cmp need to save calculations for deferred PF and AF flag calculation. Currently, they require a store per flag, which is prohibitively expensive for hot instructions like cmp. By instead pinning PF/AF temporary results to registers (x26/x27 by convention here), we eliminate many stores altogether and turn the rest into zero-cycle moves (on 64-bit at least, this isn't optimal for 32-bit emulation due to CTX->GetGPRSize shenanigans, need to check if this requirement can be lifted..). To implement, we model as SRA and then the existing SRA code is able to generate good code with little manual tuning. (Future work will get us to excellent code with more tuning ;) ). The tradeoff is reducing the working dynamic GPR set by 2 registers, which might increase spilling in some cases. I think it's worth it in practice, though. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>