From bcf79240ec09b0fa78770cae2c77a11e3b7dc6d8 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 15 Dec 2016 12:06:27 +0000 Subject: [PATCH] [TESTS] Initial commit of tests, by Andrew Tischenko git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289809 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/vector-sqrt.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/CodeGen/vector-sqrt.c diff --git a/test/CodeGen/vector-sqrt.c b/test/CodeGen/vector-sqrt.c new file mode 100644 index 0000000000..cd395a1881 --- /dev/null +++ b/test/CodeGen/vector-sqrt.c @@ -0,0 +1,27 @@ +// RUN: %clang %s -march=haswell -O3 -S -o - | FileCheck %s + +#include + +// CHECK-LABEL: sqrtd2 +// CHECK: vsqrtsd (%rdi), %xmm0, %xmm0 +// CHECK-NEXT: vsqrtsd 8(%rdi), %xmm1, %xmm1 +// CHECK-NEXT: vunpcklpd %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0],xmm1[0] +// CHECK-NEXT: retq + +__m128d sqrtd2(double* v) { + return _mm_setr_pd(__builtin_sqrt(v[0]), __builtin_sqrt(v[1])); +} + +// CHECK-LABEL: sqrtf4 +// CHECK: vsqrtss (%rdi), %xmm0, %xmm0 +// CHECK-NEXT: vsqrtss 4(%rdi), %xmm1, %xmm1 +// CHECK-NEXT: vsqrtss 8(%rdi), %xmm2, %xmm2 +// CHECK-NEXT: vsqrtss 12(%rdi), %xmm3, %xmm3 +// CHECK-NEXT: vinsertps $16, %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0],xmm1[0],xmm0[2,3] +// CHECK-NEXT: vinsertps $32, %xmm2, %xmm0, %xmm0 # xmm0 = xmm0[0,1],xmm2[0],xmm0[3] +// CHECK-NEXT: vinsertps $48, %xmm3, %xmm0, %xmm0 # xmm0 = xmm0[0,1,2],xmm3[0] +// CHECK-NEXT: retq + +__m128 sqrtf4(float* v) { + return _mm_setr_ps(__builtin_sqrtf(v[0]), __builtin_sqrtf(v[1]), __builtin_sqrtf(v[2]), __builtin_sqrtf(v[3])); +} -- 2.40.0