MCPcopy Create free account
hub / github.com/RenderKit/embree / rsqrt

Function rsqrt

common/math/vec3fa.h:149–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147 __forceinline Vec3fa sqr ( const Vec3fa& a ) { return _mm_mul_ps(a.m128,a.m128); }
148
149 __forceinline Vec3fa rsqrt( const Vec3fa& a )
150 {
151#if defined(__aarch64__)
152 __m128 r = _mm_rsqrt_ps(a.m128);
153 r = vmulq_f32(r, vrsqrtsq_f32(vmulq_f32(a.m128, r), r));
154 r = vmulq_f32(r, vrsqrtsq_f32(vmulq_f32(a.m128, r), r));
155 return r;
156#else
157
158#if defined(__AVX512VL__)
159 __m128 r = _mm_rsqrt14_ps(a.m128);
160#else
161 __m128 r = _mm_rsqrt_ps(a.m128);
162#endif
163 return _mm_add_ps(_mm_mul_ps(_mm_set1_ps(1.5f),r), _mm_mul_ps(_mm_mul_ps(_mm_mul_ps(a.m128, _mm_set1_ps(-0.5f)), r), _mm_mul_ps(r, r)));
164#endif
165 }
166
167 __forceinline Vec3fa zero_fix(const Vec3fa& a) {
168 return blendv_ps(a.m128, _mm_set1_ps(min_rcp_input), _mm_cmplt_ps (abs(a).m128, _mm_set1_ps(min_rcp_input)));

Callers 4

rcp_lengthFunction · 0.70
normalizeFunction · 0.70
normalize_safeFunction · 0.70
dnormalizeFunction · 0.70

Calls 4

_mm_rsqrt_psFunction · 0.85
_mm_add_psFunction · 0.85
_mm_mul_psFunction · 0.85
_mm_set1_psFunction · 0.85

Tested by

no test coverage detected