[Bug c/126552] const-qualified local register variable used as an asm operand is silently discarded

stefan at franke dot ms via Gcc-bugs <[email protected]> Mon, 03 Aug 2026 08:44:23 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D126552

Stefan "Bebbo" Franke <stefan at franke dot ms> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stefan at franke dot ms

--- Comment #4 from Stefan "Bebbo" Franke <stefan at franke dot ms> ---
Created attachment 65218
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D65218&action=3Dedit
Minimal m68k test case showing that GCC 13=E2=80=9316 drop the required a0 =
=3D 0
initialization for constant inline=E2=80=91asm operands, breaking the Amiga=
OS graphics
ABI.

This attachment contains a minimal m68k test case demonstrating a regressio=
n in
GCC 13=E2=80=9316 where inline asm operands bound to fixed registers are in=
correctly
optimized away. Specifically, when a constant argument is bound to register=
 a0
and passed to inline asm via an "rf" constraint, newer GCC versions generat=
e a
pseudo register (e.g., r32 =3D 0) and later eliminate it, resulting in a0 n=
ever
being initialized. The final assembly omits the required a0 =3D 0 assignmen=
t,
breaking the AmigaOS graphics ABI. The test accepts any valid zeroing seque=
nce
for a0 and fails on affected GCC versions.=