0
0
Fork 0
This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
ryujinx-final/ARMeilleure/IntermediateRepresentation
riperiperi 9db73f74cf
ARMeilleure: Respect FZ/RM flags for all floating point operations (#4618)
* ARMeilleure: Respect Fz flag for all floating point operations.

This is a change in strategy for emulating the Fz FPCR flag. Before, it was set before instructions that "needed it" and reset after. However, this missed a few hot instructions like the multiplication instruction, and the entirety of A32.

The new strategy is to set the Fz flag only in the following circumstances:

- Set to match FPCR before translated functions/loop are executed.
- Reset when calling SoftFloat methods, set when returning.
- Reset when exiting execution.

This allows us to remove the code around the existing Fz aware instructions, and get the accuracy benefits on all floating point instructions executed while in translated code.

Single step executions now need to be called with a context wrapper - right now it just contains the Fz flag initialization, and won't actually do anything on ARM.

This fixes a bug in Breath of the Wild where some physics interactions could randomly crash the game due to subnormal values not flushing to zero.

This is draft right now because I need to answer the questions:
- Does dotnet avoid changing the value of Mxcsr?
- Is it a good idea to assume that? Or should the flag set/restore be done on every managed method call, not just softfloat?
- If we assume that, do we want a unit test to verify the behaviour?

I recommend testing a bunch of games, especially games affected when this was originally added, such as #1611.

* Remove unused method

* Use FMA for Fmadd, Fmsub, Fnmadd, Fnmsub, Fmla, Fmls

...when available.

Similar implementation to A32

* Use FMA for Frecps, Frsqrts

* Don't set DAZ.

* Add round mode to ARM FP mode

* Fix mistakes

* Add test for FP state when calling managed methods

* Add explanatory comment to test.

* Cleanup

* Add A64 FPCR flags

* Vrintx_S A32 fast path on A64 backend

* Address feedback 1, re-enable DAZ

* Fix FMA instructions By Elem

* Address feedback
2023-04-10 12:22:58 +02:00
..
BasicBlock.cs Use new ArgumentNullException and ObjectDisposedException throw-helper API (#4163) 2022-12-27 20:27:11 +01:00
BasicBlockFrequency.cs Implement block placement (#1549) 2020-09-19 20:00:24 -03:00
Comparison.cs Improve branch operations (#1442) 2020-08-05 08:52:33 +10:00
IIntrusiveListNode.cs Reduce JIT GC allocations (#2515) 2021-08-17 15:08:34 -03:00
Instruction.cs Add host CPU memory barriers for DMB/DSB and ordered load/store (#3015) 2022-01-21 12:47:34 -03:00
Intrinsic.cs ARMeilleure: Respect FZ/RM flags for all floating point operations (#4618) 2023-04-10 12:22:58 +02:00
IntrusiveList.cs Reduce JIT GC allocations (#2515) 2021-08-17 15:08:34 -03:00
MemoryOperand.cs Reduce JIT GC allocations (#2515) 2021-08-17 15:08:34 -03:00
Multiplier.cs Implement JIT Arm64 backend (#4114) 2023-01-10 19:16:59 -03:00
Operand.cs Implement JIT Arm64 backend (#4114) 2023-01-10 19:16:59 -03:00
OperandKind.cs Reduce JIT GC allocations (#2515) 2021-08-17 15:08:34 -03:00
OperandType.cs Implement JIT Arm64 backend (#4114) 2023-01-10 19:16:59 -03:00
Operation.cs Optimize HybridAllocator (#2637) 2021-09-29 01:38:37 +02:00
PhiOperation.cs Make structs readonly when applicable (#4002) 2022-12-05 14:47:39 +01:00
Register.cs Make structs readonly when applicable (#4002) 2022-12-05 14:47:39 +01:00
RegisterType.cs Add most of the A32 instruction set to ARMeilleure (#897) 2020-02-24 08:20:40 +11:00