Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / target-avx-abi-diag.c
blob72de0fa2a39bdaf7c37bfe9440e6af76ebcf8599
1 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -verify=no256,no512 -o - -S
2 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx -verify=no512 -o - -S
3 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512f -verify=both -o - -S
4 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512f -target-feature +evex512 -verify=both -o - -S
5 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512f -target-feature -evex512 -verify=avx512-256 -DAVX512_ERR=1 -o - -S
6 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512f -target-feature -evex512 -verify=avx512-256 -DAVX512_ERR=2 -o - -S
7 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx512f -target-feature -evex512 -verify=avx512-256 -DAVX512_ERR=3 -o - -S
8 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx10.1-512 -verify=both -o - -S
9 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx10.1-256 -verify=avx512-256 -DAVX512_ERR=1 -o - -S
10 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx10.1-256 -verify=avx512-256 -DAVX512_ERR=2 -o - -S
11 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -target-feature +avx10.1-256 -verify=avx512-256 -DAVX512_ERR=3 -o - -S
12 // REQUIRES: x86-registered-target
14 // both-no-diagnostics
16 typedef short avx512fType __attribute__((vector_size(64)));
17 typedef short avx256Type __attribute__((vector_size(32)));
19 __attribute__((target("avx"))) void takesAvx256(avx256Type t);
20 __attribute__((target("avx512f"))) void takesAvx512(avx512fType t);
21 __attribute__((target("avx512f,evex512"))) void takesAvx512_2(avx512fType t);
22 void takesAvx256_no_target(avx256Type t);
23 void takesAvx512_no_target(avx512fType t);
25 void variadic(int i, ...);
26 __attribute__((target("avx512f"))) void variadic_err(int i, ...);
28 #if !defined(AVX512_ERR) || AVX512_ERR == 1
29 // If neither side has an attribute, warn.
30 void call_warn(void) {
31 avx256Type t1;
32 takesAvx256_no_target(t1); // no256-warning {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
34 avx512fType t2;
35 // avx512-256-error@+1 {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}}
36 takesAvx512_no_target(t2); // no512-warning {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
38 variadic(1, t1); // no256-warning {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
39 // avx512-256-error@+1 {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}}
40 variadic(3, t2); // no512-warning {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
42 #endif
44 #if !defined(AVX512_ERR) || AVX512_ERR == 2
45 // If only 1 side has an attribute, error.
46 void call_errors(void) {
47 avx256Type t1;
48 takesAvx256(t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
49 avx512fType t2;
50 // avx512-256-error@+1 {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}}
51 takesAvx512(t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
53 variadic_err(1, t1); // no256-error {{AVX vector argument of type 'avx256Type' (vector of 16 'short' values) without 'avx' enabled changes the ABI}}
54 // avx512-256-error@+1 {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}}
55 variadic_err(3, t2); // no512-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'avx512f' enabled changes the ABI}}
57 #endif
59 #if !defined(AVX512_ERR) || AVX512_ERR == 3
60 __attribute__((target("avx"))) void call_avx256_ok(void) {
61 avx256Type t;
62 takesAvx256(t);
65 // Option -mno-evex512 affects target attributes. To retain the 512-bit capability, an explict "evex512" must be added together.
66 __attribute__((target("avx512f,evex512"))) void call_avx512_ok1(void) {
67 avx512fType t;
68 takesAvx512_2(t);
71 __attribute__((target("avx512f"))) void call_avx512_ok2(void) {
72 avx512fType t;
73 takesAvx512(t); // avx512-256-error {{AVX vector argument of type 'avx512fType' (vector of 32 'short' values) without 'evex512' enabled changes the ABI}}
75 #endif