17e604485SFangrui Song // RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu x86-64 -o - |FileCheck %s --check-prefix SSE
27e604485SFangrui Song // RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -target-cpu skylake -D AVX -o - | FileCheck %s --check-prefixes AVX,SSE
37e604485SFangrui Song // 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
47e604485SFangrui Song // 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
57e604485SFangrui Song
67e604485SFangrui Song typedef float __m128 __attribute__ ((vector_size (16)));
77e604485SFangrui Song typedef float __m256 __attribute__ ((vector_size (32)));
87e604485SFangrui Song typedef float __m512 __attribute__ ((vector_size (64)));
97e604485SFangrui Song
107e604485SFangrui Song // SSE: call <4 x float> asm "vmovhlps $1, $2, $0", "=v,v,v,~{dirflag},~{fpsr},~{flags}"(i64 %0, <4 x float> %1)
testXMM(__m128 _xmm0,long _l)117e604485SFangrui Song __m128 testXMM(__m128 _xmm0, long _l) {
127e604485SFangrui Song __asm__("vmovhlps %1, %2, %0" :"=v"(_xmm0) : "v"(_l), "v"(_xmm0));
137e604485SFangrui Song return _xmm0;
147e604485SFangrui Song }
157e604485SFangrui Song
167e604485SFangrui Song // AVX: call <8 x float> asm "vmovsldup $1, $0", "=v,v,~{dirflag},~{fpsr},~{flags}"(<8 x float> %0)
testYMM(__m256 _ymm0)177e604485SFangrui Song __m256 testYMM(__m256 _ymm0) {
187e604485SFangrui Song #ifdef AVX
197e604485SFangrui Song __asm__("vmovsldup %1, %0" :"=v"(_ymm0) : "v"(_ymm0));
207e604485SFangrui Song #endif
217e604485SFangrui Song return _ymm0;
227e604485SFangrui Song }
237e604485SFangrui Song
247e604485SFangrui Song // 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)
testZMM(__m512 _zmm0,__m512 _zmm1)257e604485SFangrui Song __m512 testZMM(__m512 _zmm0, __m512 _zmm1) {
267e604485SFangrui Song #ifdef AVX512
277e604485SFangrui Song __asm__("vpternlogd $0, %1, %2, %0" :"=v"(_zmm0) : "v"(_zmm1), "v"(_zmm0));
287e604485SFangrui Song #endif
297e604485SFangrui Song return _zmm0;
307e604485SFangrui Song }
317e604485SFangrui Song
327e604485SFangrui Song // SSE: call <4 x float> asm "pcmpeqd $0, $0", "=^Yz,~{dirflag},~{fpsr},~{flags}"()
testXMM0(void)337e604485SFangrui Song __m128 testXMM0(void) {
347e604485SFangrui Song __m128 xmm0;
357e604485SFangrui Song __asm__("pcmpeqd %0, %0" :"=Yz"(xmm0));
367e604485SFangrui Song return xmm0;
377e604485SFangrui Song }
387e604485SFangrui Song
397e604485SFangrui Song // AVX: call <8 x float> asm "vpcmpeqd $0, $0, $0", "=^Yz,~{dirflag},~{fpsr},~{flags}"()
testYMM0(void)407e604485SFangrui Song __m256 testYMM0(void) {
417e604485SFangrui Song __m256 ymm0;
427e604485SFangrui Song #ifdef AVX
437e604485SFangrui Song __asm__("vpcmpeqd %0, %0, %0" :"=Yz"(ymm0));
447e604485SFangrui Song #endif
457e604485SFangrui Song return ymm0;
467e604485SFangrui Song }
477e604485SFangrui Song
487e604485SFangrui Song // AVX512: call <16 x float> asm "vpternlogd $$255, $0, $0, $0", "=^Yz,~{dirflag},~{fpsr},~{flags}"()
testZMM0(void)497e604485SFangrui Song __m512 testZMM0(void) {
507e604485SFangrui Song __m512 zmm0;
517e604485SFangrui Song #ifdef AVX512
527e604485SFangrui Song __asm__("vpternlogd $255, %0, %0, %0" :"=Yz"(zmm0));
537e604485SFangrui Song #endif
547e604485SFangrui Song return zmm0;
557e604485SFangrui Song }
56*d4cb5d9fSFangrui Song
57*d4cb5d9fSFangrui Song extern int var, arr[4];
58*d4cb5d9fSFangrui Song struct Pair { int a, b; } pair;
59*d4cb5d9fSFangrui Song
60*d4cb5d9fSFangrui Song // CHECK-LABEL: test_Ws(
61*d4cb5d9fSFangrui Song // 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*d4cb5d9fSFangrui Song // CHECK: call void asm sideeffect "// $0", "^Ws,~{dirflag},~{fpsr},~{flags}"(ptr getelementptr inbounds (%struct.Pair, ptr @pair, i32 0, i32 1))
test_Ws(void)63*d4cb5d9fSFangrui Song void test_Ws(void) {
64*d4cb5d9fSFangrui Song asm("// %p0 %p1 %p2" :: "Ws"(&var), "Ws"(&arr[3]), "Ws"(test_Ws));
65*d4cb5d9fSFangrui Song asm("// %0" :: "Ws"(&pair.b));
66*d4cb5d9fSFangrui Song }
67