diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-06-21 20:22:55 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-06-21 20:22:55 +0000 |
commit | a4d156980e69fd3787a8a3948d4f1da16b1abf32 (patch) | |
tree | 12af3b81f09e7ea714b42f022415bb63309361f6 /clang/test/CodeGen/target-features-error-2.c | |
parent | 325c7274809b637e86a8e81e7c78667d939440a8 (diff) | |
download | bcm5719-llvm-a4d156980e69fd3787a8a3948d4f1da16b1abf32.tar.gz bcm5719-llvm-a4d156980e69fd3787a8a3948d4f1da16b1abf32.zip |
[x86] AVX FP compare builtins should require AVX target feature (PR28112)
This is a fix for PR28112:
https://llvm.org/bugs/show_bug.cgi?id=28112
The FP comparison intrinsics that take an immediate parameter (rather than specifying
a comparison predicate in the function name) were added with AVX; these are macros in
avxintrin.h. This patch makes clang behavior match gcc (error if a program tries to use
these without -mavx) and matches the Intel documentation, eg:
VCMPPS: m128 _mm_cmp_ps(m128 a, __m128 b, const int imm)
'V' means this is intended to only work with the AVX form of the instruction.
Differential Revision: http://reviews.llvm.org/D21306
llvm-svn: 273311
Diffstat (limited to 'clang/test/CodeGen/target-features-error-2.c')
-rw-r--r-- | clang/test/CodeGen/target-features-error-2.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/clang/test/CodeGen/target-features-error-2.c b/clang/test/CodeGen/target-features-error-2.c index c23d152dcfb..683d9ab99ef 100644 --- a/clang/test/CodeGen/target-features-error-2.c +++ b/clang/test/CodeGen/target-features-error-2.c @@ -1,7 +1,38 @@ -// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - +// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_SSE42 +// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_1 +// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_2 +// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_3 +// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_4 + #define __MM_MALLOC_H #include <x86intrin.h> +#if NEED_SSE42 int baz(__m256i a) { return _mm256_extract_epi32(a, 3); // expected-error {{always_inline function '_mm256_extract_epi32' requires target feature 'sse4.2', but would be inlined into function 'baz' that is compiled without support for 'sse4.2'}} } +#endif + +#if NEED_AVX_1 +__m128 need_avx(__m128 a, __m128 b) { + return _mm_cmp_ps(a, b, 0); // expected-error {{'__builtin_ia32_cmpps' needs target feature avx}} +} +#endif + +#if NEED_AVX_2 +__m128 need_avx(__m128 a, __m128 b) { + return _mm_cmp_ss(a, b, 0); // expected-error {{'__builtin_ia32_cmpss' needs target feature avx}} +} +#endif + +#if NEED_AVX_3 +__m128d need_avx(__m128d a, __m128d b) { + return _mm_cmp_pd(a, b, 0); // expected-error {{'__builtin_ia32_cmppd' needs target feature avx}} +} +#endif + +#if NEED_AVX_4 +__m128d need_avx(__m128d a, __m128d b) { + return _mm_cmp_sd(a, b, 0); // expected-error {{'__builtin_ia32_cmpsd' needs target feature avx}} +} +#endif |