Bug report review request. Anyone good at SIMD?

Hello everyone,

I use AI for development, and sometimes it’s more knowledgeable than myself on certain topics. Today I spent some time hunting down what seems to be a bug in Rack’s implementation of simd::atan2. Although the bug seems legit, the topic of SIMD isn’t very familiar to me.

I’m hoping that someone with SIMD knowledge might be able to read over this and confirm that this is a legitimate bug, and not just some hallucination. I’m can confirm that the code change recommended by the AI worked for me. I don’t want to take up the Rack team’s time with a bogus bug report.

Thanks in advance, Bret

Here’s the duplicate line mentioned in the bug report:

SIMD: the concept isn’t “natural” for my old brain… :rofl: it’s a pain (and Chinese language when I read some C++ code using SIMD) in order to implement SIMD to handle upto 16-voice polyphony, for 6OP-DX synth voice module!

It is also a dilemma to handle… 6 operators by SIMD.

SIMD = 4 for the price of 1… :rofl:

Ok.

It is true the duplicated line does nothing.

It is also true that atan_result = _mm_andnot_ps(zero_mask, atan_result); does need to happen somewhere. I would put it in after adding the offset at line 295 of the source (its line numbers are off for some reason), and then just remove the duplicate.

It is also right that the bitmask x_le_0 will be true when x is zero, but that mask isn’t used anywhere else anyway so a better fix is to use < instead of <= in the first place. So line 264 becomes: v4sf x_lt_0 = _mm_cmplt_ps( x, *(v4sf*)_ps_0 ); And in line 279 change the x_le_0 to x_lt_0.

Thanks for the confirmation.

The original author of the SIMD library confirmed and patched the bug:

I’m drafting an email to vcv rack right now to report the bug.

4 Likes

Great!

1 Like

Thanks for your help. Interesting times we live in when your programming agent identifies a 10 year old bug in SSE2 implementation.