Skip to content

Commit

Permalink
Use _mm_cvtepi32_ps in place of rint on SSE2
Browse files Browse the repository at this point in the history
  • Loading branch information
crsib committed Oct 2, 2023
1 parent cdb21e3 commit 60c3f81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions libraries/lib-time-and-pitch/StaffPad/SimdTypes_sse2.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ __finl float_x4 __vecc sqrt(const float_x4 &a)
return _mm_sqrt_ps(a.s);
}

__finl float __vecc rint(float x)
{
__m128i A = _mm_cvtps_epi32(_mm_set_ss(x));
return _mm_cvtss_f32(_mm_cvtepi32_ps(A));
}

__finl float_x4 __vecc rint(const float_x4 &a)
{
__m128i A = _mm_cvtps_epi32(a.s);
Expand Down
3 changes: 2 additions & 1 deletion libraries/lib-time-and-pitch/StaffPad/TimeAndPitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ namespace {
// wrap a phase value into -PI..PI
inline float _unwrapPhase(float arg)
{
return arg - int(arg * 0.15915494309f + 0.5f) * 6.283185307f;
using namespace audio::simd;
return arg - rint(arg * 0.15915494309f) * 6.283185307f;
}

void _unwrapPhaseVec(float* v, int n)
Expand Down

0 comments on commit 60c3f81

Please sign in to comment.