]> granicus.if.org Git - clang/commitdiff
Add test case for using mmintrin (and making sure that inlining is
authorDaniel Dunbar <daniel@zuster.org>
Fri, 12 Dec 2008 19:12:02 +0000 (19:12 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 12 Dec 2008 19:12:02 +0000 (19:12 +0000)
working with and without debug info).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60960 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGen/mmintrin-test.c [new file with mode: 0644]

diff --git a/test/CodeGen/mmintrin-test.c b/test/CodeGen/mmintrin-test.c
new file mode 100644 (file)
index 0000000..97faae7
--- /dev/null
@@ -0,0 +1,26 @@
+// RUN: clang -triple i386-apple-darwin9 -emit-llvm -o %t %s && 
+// RUN: grep define %t | count 1 &&
+// RUN: clang -triple i386-apple-darwin9 -g -emit-llvm -o %t %s && 
+// RUN: grep define %t | count 1
+
+#include <mmintrin.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[]) {
+  int array[16] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
+  __m64 *p = (__m64 *)array;
+  
+  __m64 accum = _mm_setzero_si64();
+  
+  for (int i=0; i<8; ++i)
+    accum = _mm_add_pi32(p[i], accum);
+  
+  __m64 accum2 = _mm_unpackhi_pi32(accum, accum);
+  accum = _mm_add_pi32(accum, accum2);
+  
+  int result = _mm_cvtsi64_si32(accum);
+  _mm_empty();
+  printf("%d\n", result );
+  
+  return 0;
+}