MCPcopy Create free account
hub / github.com/EricLengyel/Terathon-Math-Library / VecFloor

Function VecFloor

TSSimd.h:1154–1187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1152 }
1153
1154 inline vec_float VecFloor(const vec_float& v)
1155 {
1156 #if defined(TERATHON_SSE)
1157
1158 #if defined(TERATHON_SSE4)
1159
1160 return (_mm_round_ps(v, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC));
1161
1162 #else
1163
1164 const vec_float one = VecLoadVectorConstant<0x3F800000>();
1165 const vec_float two23 = VecLoadVectorConstant<0x4B000000>();
1166
1167 vec_float result = _mm_sub_ps(_mm_add_ps(_mm_add_ps(_mm_sub_ps(v, two23), two23), two23), two23);
1168 result = _mm_sub_ps(result, _mm_and_ps(one, _mm_cmplt_ps(v, result)));
1169
1170 vec_float mask = _mm_cmplt_ps(two23, _mm_andnot_ps(VecFloatGetMinusZero(), v));
1171 return (_mm_or_ps(_mm_andnot_ps(mask, result), _mm_and_ps(mask, v)));
1172
1173 #endif
1174
1175 #elif defined(TERATHON_NEON)
1176
1177 const vec_uint32 one = vdupq_n_u32(0x3F800000);
1178 const vec_float two23 = vdupq_n_f32(8388608.0F);
1179
1180 vec_float result = vsubq_f32(vaddq_f32(vaddq_f32(vsubq_f32(v, two23), two23), two23), two23);
1181 result = vsubq_f32(result, vreinterpretq_f32_u32(vandq_u32(one, vcltq_f32(v, result))));
1182
1183 vec_uint32 mask = vcltq_f32(two23, vabsq_f32(v));
1184 return (vbslq_f32(mask, v, result));
1185
1186 #endif
1187 }
1188
1189 inline vec_float VecFloorScalar(const vec_float& v)
1190 {

Callers

nothing calls this directly

Calls 1

VecFloatGetMinusZeroFunction · 0.85

Tested by

no test coverage detected