Combine: Ignore debug instructions in volatile checks
Debug instructions are ignored during volatile access checks in the combine pass.
The combine pass in GCC now ignores DEBUG_INSNs when checking for intervening volatile memory accesses. Previously, a DEBUG_INSN could cause a non-executing memory access to be incorrectly treated as volatile, preventing valid instruction combinations. This change improves optimization opportunities by ensuring only actual volatile accesses are considered.
In Details
This commit updates the can_combine_p function in combine.cc to ignore DEBUG_INSNs when scanning for intervening volatile memory accesses. A DEBUG_INSN might retain a volatile MEM even after its associated ordinary instruction is deleted. By ignoring these debug instructions, the compiler can correctly identify opportunities to combine instructions that would otherwise be blocked by this spurious volatile reference.
- combine pass
- A GCC optimization pass that attempts to merge multiple instructions into a single, more efficient instruction where possible. It analyzes instruction sequences for opportunities to simplify or accelerate execution.
- DEBUG_INSN
- A type of instruction used for debugging purposes, which does not execute during normal program runtime. These instructions are typically stripped out by the compiler before generating the final executable.
- volatile
- A keyword that tells the compiler that a variable's value may change at any time without any action being taken by the code the compiler knows about. This prevents the compiler from optimizing away reads or writes to that variable.
- MEM
- Represents a memory operand or access within GCC's internal code representation (RTL).