From: Yegor Yefremov Date: Fri, 23 Oct 2026 23:18:15 +0000 (+0200) Subject: pcm: dmix: i386: keep the size operand in memory X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=5aa1c3d38be43f9186e325b9aec00abac4549913;p=alsa-lib.git pcm: dmix: i386: keep the size operand in memory The i386 mix_areas_*() assembly clobbers esi, edi, edx, ecx, eax and (since gcc 5, even in PIC mode) ebx. When gcc also needs ebp as frame pointer, which it does at -Os, no general purpose register is left. Commit abc9f32cf45c ("pcm: dmix: assembly: give more freedom over the constraints") relaxed the size operand from "+m" to "+&rm". With AVX512BW enabled (e.g. -march=skylake-avx512, cannonlake, icelake or x86-64-v4) and -Os or -Oz, gcc 15 and gcc 16 then fail to pick the memory alternative and abort: pcm_dmix_i386.h:52:9: error: 'asm' operand has impossible constraints or there are not enough registers As the asm already uses all registers, restore the "+m" constraint for size, as used before that commit. The loop decrementing it in memory also does read-modify-write operations on dst and sum, so the extra memory access has a negligible cost. Closes: https://github.com/alsa-project/alsa-lib/pull/537 Fixes: abc9f32cf45c ("pcm: dmix: assembly: give more freedom over the constraints") Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Yegor Yefremov Signed-off-by: Jaroslav Kysela --- diff --git a/src/pcm/pcm_dmix_i386.h b/src/pcm/pcm_dmix_i386.h index 0a56e8c6..7c9c9dcf 100644 --- a/src/pcm/pcm_dmix_i386.h +++ b/src/pcm/pcm_dmix_i386.h @@ -149,7 +149,7 @@ static void MIX_AREAS_16(unsigned int size, #ifdef BOUNDED_EBX "\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */ #endif - : [size] "+&rm" (size) + : [size] "+m" (size) #ifdef BOUNDED_EBX , [old_ebx] "=m" (old_ebx) #endif @@ -248,7 +248,7 @@ static void MIX_AREAS_16_MMX(unsigned int size, #ifdef BOUNDED_EBX "\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */ #endif - : [size] "+&rm" (size) + : [size] "+m" (size) #ifdef BOUNDED_EBX , [old_ebx] "=m" (old_ebx) #endif @@ -376,7 +376,7 @@ static void MIX_AREAS_32(unsigned int size, #ifdef BOUNDED_EBX "\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */ #endif - : [size] "+&rm" (size) + : [size] "+m" (size) #ifdef BOUNDED_EBX , [old_ebx] "=m" (old_ebx) #endif @@ -491,7 +491,7 @@ static void MIX_AREAS_24(unsigned int size, #ifdef BOUNDED_EBX "\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */ #endif - : [size] "+&rm" (size) + : [size] "+m" (size) #ifdef BOUNDED_EBX , [old_ebx] "=m" (old_ebx) #endif @@ -599,7 +599,7 @@ static void MIX_AREAS_24_CMOV(unsigned int size, #ifdef BOUNDED_EBX "\tmovl %[old_ebx], %%ebx\n" /* ebx is GOT pointer (-fPIC) */ #endif - : [size] "+&rm" (size) + : [size] "+m" (size) #ifdef BOUNDED_EBX , [old_ebx] "=m" (old_ebx) #endif