GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
m68k

M68k fixes invalid EXECUTE_IF_SET_IN_HARD_REG_SET conversion

This patch corrects a signedness issue in register number handling and a missing declaration within the m68k backend for GCC, resolving a bug in register usage…

The m68k backend for GCC had an issue with the m68k_conditional_register_usage function where the variable storing register numbers had an incorrect signedness, leading to invalid conversions when using EXECUTE_IF_SET_IN_HARD_REG_SET. Additionally, the m68k_zero_call_used_regs function was missing a necessary declaration. This patch addresses both of these problems, ensuring correct register usage and preventing potential miscompilations or crashes on the m68k architecture.

In Details

The EXECUTE_IF_SET_IN_HARD_REG_SET macro in GCC's m68k backend is designed to efficiently iterate through hard register sets. This patch fixes a signedness problem in the REGNUM variable within m68k_conditional_register_usage when used with this macro, which could lead to incorrect register numbering. It also resolves a missing declaration in m68k_zero_call_used_regs, preventing compilation issues and ensuring proper analysis of register usage during various compiler passes, such as reload.

For Context

Compilers like GCC need to keep track of which hardware registers are being used by a program. On the m68k processor, GCC has specific code to analyze and manage these registers. This commit fixes two issues in that code. First, a variable that stores register numbers was incorrectly defined as signed, which could cause problems when being used in certain optimized ways of checking multiple registers at once. Second, another internal function (m68k_zero_call_used_regs) was missing a required definition. These fixes ensure that the compiler correctly understands and manages register usage for m68k, which is crucial for generating correct and efficient machine code.

Filed Under: m68kbugfixregister-allocation