]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: dmix: i386: keep the size operand in memory
authorYegor Yefremov <yegorslists@googlemail.com>
Fri, 23 Oct 2026 23:18:15 +0000 (01:18 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 30 Nov 2026 14:04:18 +0000 (15:04 +0100)
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 <yegorslists@googlemail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_dmix_i386.h

index 0a56e8c6afb537b7f2a1095e77e75b88fdea1137..7c9c9dcf9efdbe664cdad2cb63e6d36e2ffdd7d4 100644 (file)
@@ -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