MIPS/GAS: Reinstate INSN_MULT interlock optimization
MIPS assembler re-enables optimization for multiplication instructions to prevent unnecessary NOPs.
A previously removed optimization for MIPS multiplication instructions, related to HI/LO register reads, has been reinstated in the GAS assembler. This optimization was silently dropped in a previous commit, leading to the emission of unnecessary NOP instructions before multiplication opcodes. The change corrects this by reintroducing logic to handle data dependencies, preventing regressions in test cases for multiplication and division operations on specific MIPS cores.
In Details
This commit restores the INSN_MULT interlock optimization in gas/config/tc-mips.c that was lost in commit 71400594f26d. This optimization correctly handles cases where multiplication instructions (MULO, MULOU) are preceded by an instruction reading the HI/LO registers, preventing unnecessary NOPs. The INSN_MULT flag uses negative logic and needs to be cleared when no previous instruction is available in insns_between to correctly suppress NOPs for DIV/DIVU and related macros. This fix addresses test regressions on R3900 and ensures consistent behavior across targets.
- GAS
- The GNU Assembler, part of the GNU Binutils project. It translates assembly language code into machine code.
- INSN_MULT
- An opcode flag used in the MIPS assembler to mark multiplication instructions that have specific interlock requirements. This flag was previously removed and is now reinstated.
- HI/LO registers
- Special MIPS registers used to store the high and low 32-bit parts of the result from multiplication (MULT, MULTU) and division (DIV, DIVU) operations.
- NOP
- No Operation. An instruction that does nothing. NOPs are often used for timing, padding, or to fill pipeline stages.
- R3900
- A specific MIPS processor core, likely from Toshiba, which has particular pipeline behavior and interlock requirements that this commit addresses.