Re: [PATCH] x86/local: Remove trailing semicolon from _ASM_XADD in local_add_return()

From: H. Peter Anvin

Date: Sat Feb 14 2026 - 19:55:21 EST


On February 12, 2026 2:51:02 AM PST, Uros Bizjak <ubizjak@xxxxxxxxx> wrote:
>Remove the trailing semicolon from the inline assembly statement in
>local_add_return().
>
>The _ASM_XADD macro already expands to a complete instruction, making
>the extra semicolon unnecessary. More importantly, the stray semicolon
>causes GCC to treat the inline asm as containing multiple instructions,
>which can skew its internal instruction count estimation and affect
>optimization heuristics.
>
>No functional change intended.
>
>Signed-off-by: Uros Bizjak <ubizjak@xxxxxxxxx>
>Cc: Thomas Gleixner <tglx@xxxxxxxxxx>
>Cc: Ingo Molnar <mingo@xxxxxxxxxx>
>Cc: Borislav Petkov <bp@xxxxxxxxx>
>Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
>Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
>---
> arch/x86/include/asm/local.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
>index 59aa966dc212..4957018fef3e 100644
>--- a/arch/x86/include/asm/local.h
>+++ b/arch/x86/include/asm/local.h
>@@ -106,7 +106,7 @@ static inline bool local_add_negative(long i, local_t *l)
> static inline long local_add_return(long i, local_t *l)
> {
> long __i = i;
>- asm volatile(_ASM_XADD "%0, %1;"
>+ asm volatile(_ASM_XADD "%0, %1"
> : "+r" (i), "+m" (l->a.counter)
> : : "memory");
> return i + __i;

Are you sure that gcc treats an empty statement or line as something that should be counted? It is awkward as heck if so, and really ought to be fixed in gcc.