Index: include/clang/Basic/BuiltinsX86.def =================================================================== --- include/clang/Basic/BuiltinsX86.def +++ include/clang/Basic/BuiltinsX86.def @@ -30,6 +30,12 @@ // can use it? BUILTIN(__builtin_cpu_supports, "bcC*", "nc") +// Undefined Values +// +TARGET_BUILTIN(__builtin_ia32_undef128, "V2d", "nc", "") +TARGET_BUILTIN(__builtin_ia32_undef256, "V4d", "nc", "") +TARGET_BUILTIN(__builtin_ia32_undef512, "V8d", "nc", "") + // 3DNow! // TARGET_BUILTIN(__builtin_ia32_femms, "v", "", "3dnow") Index: lib/CodeGen/CGBuiltin.cpp =================================================================== --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -6090,6 +6090,10 @@ Value *F = CGM.getIntrinsic(Intrinsic::prefetch); return Builder.CreateCall(F, {Address, RW, Locality, Data}); } + case X86::BI__builtin_ia32_undef128: + case X86::BI__builtin_ia32_undef256: + case X86::BI__builtin_ia32_undef512: + return UndefValue::get(ConvertType(E->getType())); case X86::BI__builtin_ia32_vec_init_v8qi: case X86::BI__builtin_ia32_vec_init_v4hi: case X86::BI__builtin_ia32_vec_init_v2si: Index: lib/Headers/avx512fintrin.h =================================================================== --- lib/Headers/avx512fintrin.h +++ lib/Headers/avx512fintrin.h @@ -57,6 +57,30 @@ return (__m512i)(__v8di){ 0, 0, 0, 0, 0, 0, 0, 0 }; } +static __inline__ __m512d __DEFAULT_FN_ATTRS +_mm512_undefined_pd() +{ + return (__m512d)__builtin_ia32_undef512(); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS +_mm512_undefined() +{ + return (__m512)__builtin_ia32_undef512(); +} + +static __inline__ __m512 __DEFAULT_FN_ATTRS +_mm512_undefined_ps() +{ + return (__m512)__builtin_ia32_undef512(); +} + +static __inline__ __m512i __DEFAULT_FN_ATTRS +_mm512_undefined_epi32() +{ + return (__m512i)__builtin_ia32_undef512(); +} + static __inline __m512i __DEFAULT_FN_ATTRS _mm512_maskz_set1_epi32(__mmask16 __M, int __A) { Index: lib/Headers/avxintrin.h =================================================================== --- lib/Headers/avxintrin.h +++ lib/Headers/avxintrin.h @@ -900,6 +900,24 @@ } /* Create vectors */ +static __inline__ __m256d __DEFAULT_FN_ATTRS +_mm256_undefined_pd() +{ + return (__m256d)__builtin_ia32_undef256(); +} + +static __inline__ __m256 __DEFAULT_FN_ATTRS +_mm256_undefined_ps() +{ + return (__m256)__builtin_ia32_undef256(); +} + +static __inline__ __m256i __DEFAULT_FN_ATTRS +_mm256_undefined_si256() +{ + return (__m256i)__builtin_ia32_undef256(); +} + static __inline __m256d __DEFAULT_FN_ATTRS _mm256_set_pd(double __a, double __b, double __c, double __d) { Index: lib/Headers/emmintrin.h =================================================================== --- lib/Headers/emmintrin.h +++ lib/Headers/emmintrin.h @@ -523,6 +523,12 @@ } static __inline__ __m128d __DEFAULT_FN_ATTRS +_mm_undefined_pd() +{ + return (__m128d)__builtin_ia32_undef128(); +} + +static __inline__ __m128d __DEFAULT_FN_ATTRS _mm_set_sd(double __w) { return (__m128d){ __w, 0 }; @@ -1116,6 +1122,12 @@ } static __inline__ __m128i __DEFAULT_FN_ATTRS +_mm_undefined_si128() +{ + return (__m128i)__builtin_ia32_undef128(); +} + +static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_set_epi64x(long long q1, long long q0) { return (__m128i){ q0, q1 }; Index: lib/Headers/xmmintrin.h =================================================================== --- lib/Headers/xmmintrin.h +++ lib/Headers/xmmintrin.h @@ -577,6 +577,12 @@ } static __inline__ __m128 __DEFAULT_FN_ATTRS +_mm_undefined_ps() +{ + return (__m128)__builtin_ia32_undef128(); +} + +static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_set_ss(float __w) { return (__m128){ __w, 0, 0, 0 }; Index: test/CodeGen/sse-undefined.c =================================================================== --- test/CodeGen/sse-undefined.c +++ test/CodeGen/sse-undefined.c @@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -o - | not grep "xmm" +// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -o - | not grep "ymm" +// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -o - | not grep "zmm" + +// Don't include mm_malloc.h, it's system specific. +#define __MM_MALLOC_H + +#include + +__m128 test_mm_undefined_ps() { + return _mm_undefined_ps(); +} + +__m128d test_mm_undefined_pd() { + return _mm_undefined_pd(); +} + +__m128i test_mm_undefined_si128() { + return _mm_undefined_si128(); +} + +__m256 test_mm256_undefined_ps() { + return _mm256_undefined_ps(); +} + +__m256d test_mm256_undefined_pd() { + return _mm256_undefined_pd(); +} + +__m256i test_mm256_undefined_si256() { + return _mm256_undefined_si256(); +} + +__m512 test_mm512_undefined() { + return _mm512_undefined(); +} + +__m512 test_mm512_undefined_ps() { + return _mm512_undefined_ps(); +} + +__m512d test_mm512_undefined_pd() { + return _mm512_undefined_pd(); +} + +__m512i test_mm512_undefined_epi32() { + return _mm512_undefined_epi32(); +} +