Improve `mov<mode>cc' expander for floating-point moves
Enhances LoongArch's conditional floating-point moves using integer comparison results and optimizes GPR<->FCC move costs.
This update refines the LoongArch mov<mode>cc expander to support conditional floating-point moves based on integer comparison outcomes. It also adjusts the cost estimates for moving data between general-purpose registers (GPRs) and floating-point condition registers (FCCs). By setting these costs more accurately, the compiler can avoid unnecessary register spilling and generate more efficient code for conditional assignments involving floating-point values.
In Details
The loongarch_expand_conditional_move function has been modified to allow conditional FP moves (fsel) to be predicated on integer condition codes. This is achieved by introducing intermediate GPR-to-FCC moves. The loongarch_move_to_gpr_cost and loongarch_move_from_gpr_cost functions have been updated to reflect the actual cost of these GPR/FCC transfers, rather than a generic large cost. This accuracy prevents unnecessary spill code that could arise from a misestimated cost and improves the effectiveness of conditional move generation for floating-point values.
- LoongArch
- A RISC instruction set architecture developed in China, designed for high performance and efficiency. GCC has a backend for this architecture.
- mov<mode>cc
- A machine-dependent instruction pattern in GCC's RTL (Representation Tree) that represents a conditional move operation based on a specific mode (e.g., floating-point).
- expander
- A piece of code in a compiler backend that translates a high-level RTL construct or operation into a sequence of specific machine instructions.
- floating-point
- Numbers that have a fractional part, represented in computers using a format with a significand and an exponent. Operations on these numbers are distinct from integer operations.
- GPR
- General-Purpose Register. A register in a CPU that can be used for various purposes, such as holding data, addresses, or intermediate results.
- FCC
- Floating-Point Condition Code register. A special register used to store the results of floating-point comparisons.
- spill code
- Code generated by a compiler to save register values onto the stack when there are not enough registers available, and to restore them later.