[FFmpeg-devel] [PATCH] avutil/x86/intmath: remove inline asm implementations for clip functions

Martin Storsjö martin at martin.st
Tue Jun 3 19:40:17 EEST 2025


On Tue, 3 Jun 2025, Niklas Haas wrote:

> On Mon, 02 Jun 2025 15:41:33 -0300 James Almer <jamrial at gmail.com> wrote:
>> GCC/Clang is smart enough to emit minss/maxss the same way as these functions.
>> The only theoretical benefit was in x86_32, where x87 floats are used, but the
>> penalty of making the clipping opaque to the compiler's scheduler plus moving
>> values from mmx regs to xmm and back will offset any potential speedup.
>> x86_32 builds targetting anything made in the last two decades and a half
>> should use -msse -mfp=sse anyway.
>
> As mention in the another thread, x87 FPU usage causes non-bitexact results in
> swscale. Should we at this point consider setting -mfpu=sse by default for
> x86_32 builds?

I don't object to doing that - however, if we have float code, that is 
expected to be bitexact, the root issue still remains even if we force SSE 
fpmath on x86. The same issue could crop up on any 
architecture/OS/compiler combo, it's just that x87 math shows the issues 
much easier. (Not making a judgement whether that's an issue we want to 
deal with, or whether we're ok with having bitexact code that relies on 
float math that behaves close enough to some specific reference.)

// Martin



More information about the ffmpeg-devel mailing list