diff --git a/lib/Headers/xmmintrin.h b/lib/Headers/xmmintrin.h index e616157b04..e2480ec7a0 100644 --- a/lib/Headers/xmmintrin.h +++ b/lib/Headers/xmmintrin.h @@ -95,7 +95,8 @@ _mm_div_ps(__m128 a, __m128 b) static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) _mm_sqrt_ss(__m128 a) { - return __builtin_ia32_sqrtss(a); + __m128 c = __builtin_ia32_sqrtss(a); + return (__m128) { c[0], a[1], a[2], a[3] }; } static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) @@ -107,7 +108,8 @@ _mm_sqrt_ps(__m128 a) static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) _mm_rcp_ss(__m128 a) { - return __builtin_ia32_rcpss(a); + __m128 c = __builtin_ia32_rcpss(a); + return (__m128) { c[0], a[1], a[2], a[3] }; } static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) @@ -119,7 +121,8 @@ _mm_rcp_ps(__m128 a) static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) _mm_rsqrt_ss(__m128 a) { - return __builtin_ia32_rsqrtss(a); + __m128 c = __builtin_ia32_rsqrtss(a); + return (__m128) { c[0], a[1], a[2], a[3] }; } static __inline__ __m128 __attribute__((__always_inline__, __nodebug__)) diff --git a/test/CodeGen/sse-builtins.c b/test/CodeGen/sse-builtins.c index 0e48560b08..400209fca2 100644 --- a/test/CodeGen/sse-builtins.c +++ b/test/CodeGen/sse-builtins.c @@ -1,8 +1,39 @@ // RUN: %clang_cc1 -ffreestanding -triple i386-apple-darwin9 -target-cpu pentium4 -target-feature +sse4.1 -g -emit-llvm %s -o - | FileCheck %s +#include #include #include +__m128 test_rsqrt_ss(__m128 x) { + // CHECK: define {{.*}} @test_rsqrt_ss + // CHECK: call <4 x float> @llvm.x86.sse.rsqrt.ss + // CHECK: extractelement <4 x float> {{.*}}, i32 0 + // CHECK: extractelement <4 x float> {{.*}}, i32 1 + // CHECK: extractelement <4 x float> {{.*}}, i32 2 + // CHECK: extractelement <4 x float> {{.*}}, i32 3 + return _mm_rsqrt_ss(x); +} + +__m128 test_rcp_ss(__m128 x) { + // CHECK: define {{.*}} @test_rcp_ss + // CHECK: call <4 x float> @llvm.x86.sse.rcp.ss + // CHECK: extractelement <4 x float> {{.*}}, i32 0 + // CHECK: extractelement <4 x float> {{.*}}, i32 1 + // CHECK: extractelement <4 x float> {{.*}}, i32 2 + // CHECK: extractelement <4 x float> {{.*}}, i32 3 + return _mm_rcp_ss(x); +} + +__m128 test_sqrt_ss(__m128 x) { + // CHECK: define {{.*}} @test_sqrt_ss + // CHECK: call <4 x float> @llvm.x86.sse.sqrt.ss + // CHECK: extractelement <4 x float> {{.*}}, i32 0 + // CHECK: extractelement <4 x float> {{.*}}, i32 1 + // CHECK: extractelement <4 x float> {{.*}}, i32 2 + // CHECK: extractelement <4 x float> {{.*}}, i32 3 + return _mm_sqrt_ss(x); +} + __m128 test_loadl_pi(__m128 x, void* y) { // CHECK: define {{.*}} @test_loadl_pi // CHECK: load <2 x float>* {{.*}}, align 1{{$}}