MIPS/GAS: Reinstate INSN_MULT interlock optimization
Restores a previously removed optimization in GAS for MIPS to prevent unnecessary NOPs before multiplication instructions on Toshiba TX39.
This patch reinstates an optimization in the GNU Assembler (GAS) for MIPS processors that was inadvertently removed in a previous commit. The optimization correctly handles interlocks for multiplication instructions on the Toshiba TX39 by ensuring that division instructions (DIV, DIVU) do not immediately follow instructions that read the HI/LO registers. Without this, unnecessary NOPs were being inserted, causing test regressions. The patch also updates comments and adjusts test cases.
In Details
GAS on MIPS has specific logic in insns_between to handle pipeline hazards related to HI/LO register reads preceding division instructions. This optimization, controlled by the INSN_MULT flag (which uses negative logic), was removed in commit 71400594f26d. This patch restores that logic to prevent NOP insertion issues on targets like the R3900, which were failing tests. It also clarifies comments about the limited applicability of this optimization.
- GAS
- GNU Assembler, part of the GNU Binutils package, responsible for translating assembly language code into machine code.
- INSN_MULT
- An opcode flag in the MIPS instruction set used to indicate specific scheduling behaviors related to multiplication instructions.
- interlock optimization
- Compiler or assembler optimizations that ensure correct instruction sequencing by inserting necessary delays (e.g., NOPs) to avoid pipeline hazards or data dependencies.
- NOP
- No-Operation instruction; a placeholder instruction that does nothing but consume one clock cycle.
- HI/LO registers
- Special-purpose registers on MIPS processors that store the high and low parts of multiplication or division results.
- Toshiba TX39
- A specific MIPS processor that has particular pipeline constraints related to the HI and LO registers, especially concerning division and multiply-add instructions.