diff --git a/clang/include/clang/Basic/BuiltinsX86.def b/clang/include/clang/Basic/BuiltinsX86.def index 9e1bb99392e9..f44aed6f9548 100644 --- a/clang/include/clang/Basic/BuiltinsX86.def +++ b/clang/include/clang/Basic/BuiltinsX86.def @@ -346,6 +346,7 @@ BUILTIN(__builtin_ia32_ptestz128, "iV2LLiV2LLi", "") BUILTIN(__builtin_ia32_ptestc128, "iV2LLiV2LLi", "") BUILTIN(__builtin_ia32_ptestnzc128, "iV2LLiV2LLi", "") BUILTIN(__builtin_ia32_mpsadbw128, "V16cV16cV16ci", "") +BUILTIN(__builtin_ia32_phminposuw128, "V8sV8s", "") // SSE 4.2 BUILTIN(__builtin_ia32_pcmpistrm128, "V16cV16cV16cIc", "") diff --git a/clang/lib/Headers/smmintrin.h b/clang/lib/Headers/smmintrin.h index 1ca70f8d368f..7e3babd743b1 100644 --- a/clang/lib/Headers/smmintrin.h +++ b/clang/lib/Headers/smmintrin.h @@ -332,6 +332,12 @@ _mm_packus_epi32(__m128i __V1, __m128i __V2) /* SSE4 Multiple Packed Sums of Absolute Difference. */ #define _mm_mpsadbw_epu8(X, Y, M) __builtin_ia32_mpsadbw128((X), (Y), (M)) +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) +_mm_minpos_epu16(__m128i __V) +{ + return (__m128i) __builtin_ia32_phminposuw128((__v8hi)__V); +} + /* These definitions are normally in nmmintrin.h, but gcc puts them in here so we'll do the same. */ #ifdef __SSE4_2__ diff --git a/clang/test/CodeGen/sse-builtins.c b/clang/test/CodeGen/sse-builtins.c index 64ee4c970fe0..07c33e343590 100644 --- a/clang/test/CodeGen/sse-builtins.c +++ b/clang/test/CodeGen/sse-builtins.c @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -ffreestanding -triple i386-apple-darwin9 -target-cpu pentium4 -target-feature +sse4.1 -g -emit-llvm %s -o - | FileCheck %s #include +#include __m128 test_loadl_pi(__m128 x, void* y) { // CHECK: define {{.*}} @test_loadl_pi @@ -102,3 +103,7 @@ __m128i test_loadl_epi64(void* y) { // CHECK: load i64* {{.*}}, align 1{{$}} return _mm_loadl_epi64(y); } + +__m128i test_mm_minpos_epu16(__m128i x) { + return _mm_minpos_epu16(x); +}