IRA now allows multiple uses within an instruction
The IRA pass in GCC has been updated to correctly handle situations where a register is used multiple times within a single instruction, preventing an assertio…
The GCC Instruction Register Allocator (IRA) previously asserted when encountering multiple uses of a register within the same intermediate representation instruction. This change relaxes the assertion in combine_and_move_insns because the goal is to prevent a register from being used by multiple instructions, not multiple times within a single instruction. This fix addresses a scenario seen with asm_operands where a register was legitimately referenced multiple times.
In Details
The IRA (Instruction Register Allocator) pass in GCC is a key component in the register allocation pipeline, operating on RTL (Register Transfer Language) to assign physical registers to pseudos. The fix specifically targets an assertion in ira.cc within the combine_and_move_insns function. This assertion was overly aggressive, failing when a single RTL insn legitimately had multiple uses of the same register, particularly in the context of asm_operands. The core principle is that while a definition should not be trivially moved or deleted if its register is used by multiple separate in…
For Context
Imagine a compiler as a complex machine that translates your human-readable code into instructions a computer's processor can understand. One of its crucial jobs is managing 'registers' — tiny, super-fast storage locations inside the processor. The Instruction Register Allocator (IRA) is a part of the GCC compiler that decides which data should go into which register at any given moment to make your program run efficiently. This commit fixes a specific problem where the IRA was too strict about how it tracked register usage. It would flag an error if a single instruction referred to the same register multiple times, even when that was perfectly valid, for example, when using inline assembly (asm_operands). The change differentiates between a register being used across *different* instructions (which needs careful handling) and being used multiple times *within* the *same* instruction (which is often fine), preventing the compiler from crashing in valid scenarios.