From: Ekaterina Romanova Date: Fri, 22 Jan 2016 06:50:50 +0000 (+0000) Subject: 2 missing intrinsics _cvtss_sh and _mm_cvtps_ph were added to the intrinsics header... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=06dd7db57761509c77c4812b448a8f09b5fbf64a;p=clang 2 missing intrinsics _cvtss_sh and _mm_cvtps_ph were added to the intrinsics header f16intrin.h Differential Revision: http://reviews.llvm.org/D16177 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258492 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Headers/f16cintrin.h b/lib/Headers/f16cintrin.h index c655d98ee9..0ed966abbc 100644 --- a/lib/Headers/f16cintrin.h +++ b/lib/Headers/f16cintrin.h @@ -29,10 +29,23 @@ #define __F16CINTRIN_H /* Define the default attributes for the functions in this file. */ -#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("f16c"))) +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("f16c"))) -#define _mm_cvtps_ph(a, imm) __extension__ ({ \ - (__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm)); }) +static __inline float __DEFAULT_FN_ATTRS +_cvtsh_ss(unsigned short a) +{ + __v8hi v = {(short)a, 0, 0, 0, 0, 0, 0, 0}; + __v4sf r = __builtin_ia32_vcvtph2ps(v); + return r[0]; +} + +#define _cvtss_sh(a, imm) \ + ((unsigned short)(((__v8hi)__builtin_ia32_vcvtps2ph((__v4sf){a, 0, 0, 0}, \ + (imm)))[0])) + +#define _mm_cvtps_ph(a, imm) \ + ((__m128i)__builtin_ia32_vcvtps2ph((__v4sf)(__m128)(a), (imm))) static __inline __m128 __DEFAULT_FN_ATTRS _mm_cvtph_ps(__m128i __a) diff --git a/test/CodeGen/f16c-builtins.c b/test/CodeGen/f16c-builtins.c index f9cfa0d8fb..b0f660ab0a 100644 --- a/test/CodeGen/f16c-builtins.c +++ b/test/CodeGen/f16c-builtins.c @@ -5,6 +5,18 @@ #include +float test_cvtsh_ss(unsigned short a) { + // CHECK-LABEL: test_cvtsh_ss + // CHECK: @llvm.x86.vcvtph2ps.128 + return _cvtsh_ss(a); +} + +unsigned short test_cvtss_sh(float a) { + // CHECK-LABEL: test_cvtss_sh + // CHECK: @llvm.x86.vcvtps2ph.128 + return _cvtss_sh(a, 0); +} + __m128 test_mm_cvtph_ps(__m128i a) { // CHECK-LABEL: test_mm_cvtph_ps // CHECK: @llvm.x86.vcvtph2ps.128