Skip to content

pcm: dmix: i386: keep the size operand in memory - #537

Open
yegorich wants to merge 1 commit into
alsa-project:masterfrom
yegorich:dmix-i386-size-constraint
Open

yegorich wants to merge 1 commit into
alsa-project:masterfrom
yegorich:dmix-i386-size-constraint

Conversation

@yegorich

Copy link
Copy Markdown

The i386 mix_areas_*() assembly clobbers esi, edi, edx, ecx, eax and ebx. At -Os gcc also uses ebp as frame pointer, so no general purpose register is left.

Since abc9f32 ("pcm: dmix: assembly: give more freedom over the constraints") the size operand is "+&rm". With AVX512BW enabled (-march=skylake-avx512, cannonlake, icelake-client, x86-64-v4, or -mavx512bw) and -Os/-Oz, gcc 15.3 and 16.2 then fail:

pcm_dmix_i386.h:52:9: error: 'asm' operand has impossible constraints or there are not enough registers

This patch restores the "+m" constraint used before that commit for size, in all five functions.

Found by the Buildroot autobuilders: https://autobuild.buildroot.org/results/ff613c2d94c35a38a5886b70d72aa37b58440b5d

Testing: compiled pcm_dmix_i386.h with gcc 15.3.0 and 16.2.0 (i686), for -O0/-O1/-O2/-O3/-Os/-Oz × 9 -march values × with/without -fPIC. Before: all -Os/-Oz + AVX512BW combinations fail. After: all 108 combinations build. A full i686 Buildroot build of alsa-lib with the failing configuration passes as well.

🤖 Generated with Claude Code

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 abc9f32 ("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.

Fixes: abc9f32 ("pcm: dmix: assembly: give more freedom over the constraints")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant