[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / X86 / inline-asm-constraints.c
blobc89d94cab946b357ac5a508dcc70963dda011327
1 // RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu x86-64 -o - |FileCheck %s --check-prefix SSE
2 // RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu skylake -D AVX -o - | FileCheck %s --check-prefixes AVX,SSE
3 // RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu skylake-avx512 -D AVX512 -D AVX -o - | FileCheck %s --check-prefixes AVX512,AVX,SSE
4 // RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu knl -D AVX -D AVX512 -o - | FileCheck %s --check-prefixes AVX512,AVX,SSE
6 typedef float __m128 __attribute__ ((vector_size (16)));
7 typedef float __m256 __attribute__ ((vector_size (32)));
8 typedef float __m512 __attribute__ ((vector_size (64)));
10 // SSE: call <4 x float> asm "vmovhlps $1, $2, $0", "=v,v,v,~{dirflag},~{fpsr},~{flags}"(i64 %0, <4 x float> %1)
11 __m128 testXMM(__m128 _xmm0, long _l) {
12 __asm__("vmovhlps %1, %2, %0" :"=v"(_xmm0) : "v"(_l), "v"(_xmm0));
13 return _xmm0;
16 // AVX: call <8 x float> asm "vmovsldup $1, $0", "=v,v,~{dirflag},~{fpsr},~{flags}"(<8 x float> %0)
17 __m256 testYMM(__m256 _ymm0) {
18 #ifdef AVX
19 __asm__("vmovsldup %1, %0" :"=v"(_ymm0) : "v"(_ymm0));
20 #endif
21 return _ymm0;
24 // AVX512: call <16 x float> asm "vpternlogd $$0, $1, $2, $0", "=v,v,v,~{dirflag},~{fpsr},~{flags}"(<16 x float> %0, <16 x float> %1)
25 __m512 testZMM(__m512 _zmm0, __m512 _zmm1) {
26 #ifdef AVX512
27 __asm__("vpternlogd $0, %1, %2, %0" :"=v"(_zmm0) : "v"(_zmm1), "v"(_zmm0));
28 #endif
29 return _zmm0;
32 // SSE: call <4 x float> asm "pcmpeqd $0, $0", "=^Yz,~{dirflag},~{fpsr},~{flags}"()
33 __m128 testXMM0(void) {
34 __m128 xmm0;
35 __asm__("pcmpeqd %0, %0" :"=Yz"(xmm0));
36 return xmm0;
39 // AVX: call <8 x float> asm "vpcmpeqd $0, $0, $0", "=^Yz,~{dirflag},~{fpsr},~{flags}"()
40 __m256 testYMM0(void) {
41 __m256 ymm0;
42 #ifdef AVX
43 __asm__("vpcmpeqd %0, %0, %0" :"=Yz"(ymm0));
44 #endif
45 return ymm0;
48 // AVX512: call <16 x float> asm "vpternlogd $$255, $0, $0, $0", "=^Yz,~{dirflag},~{fpsr},~{flags}"()
49 __m512 testZMM0(void) {
50 __m512 zmm0;
51 #ifdef AVX512
52 __asm__("vpternlogd $255, %0, %0, %0" :"=Yz"(zmm0));
53 #endif
54 return zmm0;
57 extern int var, arr[4];
58 struct Pair { int a, b; } pair;
60 // CHECK-LABEL: test_Ws(
61 // CHECK: call void asm sideeffect "// ${0:p} ${1:p} ${2:p}", "^Ws,^Ws,^Ws,~{dirflag},~{fpsr},~{flags}"(ptr @var, ptr getelementptr inbounds ([4 x i32], ptr @arr, i64 0, i64 3), ptr @test_Ws)
62 // CHECK: call void asm sideeffect "// $0", "^Ws,~{dirflag},~{fpsr},~{flags}"(ptr getelementptr inbounds (%struct.Pair, ptr @pair, i32 0, i32 1))
63 void test_Ws(void) {
64 asm("// %p0 %p1 %p2" :: "Ws"(&var), "Ws"(&arr[3]), "Ws"(test_Ws));
65 asm("// %0" :: "Ws"(&pair.b));