Which Abs is faster?
Archive · 2007 4 old posts
From the original SynthMaker forum (2004–2014), with its members’ names and dates.
TomC ·
I noticed that in your compressor coding you use out = (in >= 0 & in) - (in < 0 & in); to compute the absolute value of a stream.
I use out = max(in, 0-in); in a smooth limiter I'm writing right know.
I don't know the internals of the 'max' function, so: which one's faster?
Cheers,
Tom
TheAudiophileDutchman ·
This one is: 🙂
stage(0) { absmask = 3.4e38 | 0.999999 | 0.1; }
out = in & absmask;
or even better in assembler:
int absmask=2147483647; // 0x7fffffff
movaps xmm0,in;
andps xmm0,absmask;
movaps out,xmm0;
TomC ·
TheAudiophileDutchman wrote: This one is: 🙂
or even better in assembler:
int absmask=2147483647; // 0x7fffffff
movaps xmm0,in;
andps xmm0,absmask;
movaps out,xmm0;
Hmh, throwing away the sign bit is quite clever if the incoming stream happens to be 8 byte.
I wouldn't use this on 16 byte values, though 😉
Thanks for that nice idea.
Tom
stefan ·
The method TheAudiophileDutchman described is for 32bit floats, it works on the ordinary stream types in SM.