[PATCH] D116238: [mips] Add -mfix4300 flag to enable vr4300 mulmul bugfix pass
Random via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 23 13:48:32 PST 2021
Random06457 created this revision.
Random06457 added a reviewer: atanasyan.
Herald added subscribers: dang, jrtc27, hiraditya, arichardson, mgorny, sdardis.
Random06457 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.
Early revisions of the VR4300 have a hardware bug where two consecutive multiplications can produce an incorrect result in the second multiply.
This revision adds the `-mfix4300` flag to llvm (and clang) which, when passed, provides a software fix for this issue.
**More precise description of the "mulmul" bug:**
1: mul.[s,d] fd,fs,ft
2: mul.[s,d] fd,fs,ft or [D]MULT[U] rs,rt
When the above sequence is executed by the CPU, if at least one of the source operands of the first mul instruction happens to be `sNaN`, `0` or `Infinity`, then the second mul instruction may produce an incorrect result.
This can happen both if the two mul instructions are next to each other of if the first one is in a delay slot and the second is the first instruction of the branch target.
**Description of the fix:**
This fix adds a backend pass to llvm which scans for mul instructions in each basic block and happens a nop whenever the following conditions are met:
- The current instruction is a single or double-precision floating-point mul instruction.
- The next instrution is either a mul instruction (any kind) or a branch instruction.
I chose `-mfix4300` as a name for the flag to follow the GCC nomenclature but I don't know if this is a good name.
rG LLVM Github Monorepo
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 7576 bytes
Desc: not available
More information about the cfe-commits