__m128d test_mm_cvtsi32_sd(__m128d A, int B) { // DAG-LABEL: test_mm_cvtsi32_sd // DAG: sitofp i32 %{{.*}} to double // DAG: insertelement <2 x double> %{{.*}}, double %{{.*}}, i32 0 // // ASM-LABEL: test_mm_cvtsi32_sd // ASM: cvtsi2sdl return _mm_cvtsi32_sd(A, B); }
/** @brief Rounds floating-point number to the nearest integer not smaller than the original. The function computes an integer i such that: \f[i \le \texttt{value} < i+1\f] @param value floating-point number. If the value is outside of INT_MIN ... INT_MAX range, the result is not defined. */ CV_INLINE int cvCeil( double value ) { #if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__&& !defined __APPLE__)) && !defined(__CUDACC__) __m128d t = _mm_set_sd( value ); int i = _mm_cvtsd_si32(t); return i + _mm_movemask_pd(_mm_cmplt_sd(_mm_cvtsi32_sd(t,i), t)); #elif defined __GNUC__ int i = (int)value; return i + (i < value); #else int i = cvRound(value); float diff = (float)(i - value); return i + (diff < 0); #endif }
F64 round(F64 val) { #ifdef USE_SSE4 __m128d t = _mm_set_sd(val); t = _mm_round_sd(t, t, _MM_FROUND_TO_NEAREST_INT); _mm_store_sd(&val, t); #elif defined(USE_SSE2) __m128d t = _mm_set_sd(val); U32 i = (U32)_mm_cvtsd_si32(t); t = _mm_cvtsi32_sd(t, (int32)i); _mm_store_sd(&val, t); #else val = core_floor(val + 0.5); #endif return val; }
F64 ceil(F64 val) { #ifdef USE_SSE4 __m128d t = _mm_set_sd(val); t = _mm_ceil_sd(t, t); _mm_store_sd(&val, t); #elif defined(USE_SSE2) val += 0.5; __m128d t = _mm_set_sd(val); U32 i = (U32)_mm_cvtsd_si32(t); t = _mm_cvtsi32_sd(t, (int32)i); _mm_store_sd(&val, t); #else val = core_ceil(val); #endif return val; }
void convert_dword_to_double(double* result, UINT32 i) { __m128d mmin, mmout; mmin = _mm_setzero_pd(); mmout = _mm_cvtsi32_sd(mmin,i); _mm_store_sd(result, mmout); }