aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/count-builtins.c
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-01-28 18:42:57 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-01-28 18:42:57 +0000
commita49a2839266f0bac2b6286e9f49fdc0c292938fe (patch)
treefc9198c2a440131d8d480ab4748762a9b1c7c520 /test/CodeGen/count-builtins.c
parent9f1c49c57d8a5215c3f662b0f00e830a0b06d6de (diff)
Make the __builtin_c[lt]zs builtins target independent.
There is really no reason to have these only available on x86. It's just __builtin_c[tl]z for shorts. Modernize the test while at it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149183 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/count-builtins.c')
-rw-r--r--test/CodeGen/count-builtins.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/CodeGen/count-builtins.c b/test/CodeGen/count-builtins.c
new file mode 100644
index 0000000000..e6133c5cf0
--- /dev/null
+++ b/test/CodeGen/count-builtins.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+int leading, trailing, pop;
+
+void test_i16(short P) {
+ leading = __builtin_clzs(P);
+ trailing = __builtin_ctzs(P);
+
+// CHECK: @test_i16
+// CHECK: call i16 @llvm.ctlz.i16
+// CHECK: call i16 @llvm.cttz.i16
+}
+
+void test_i32(int P) {
+ leading = __builtin_clz(P);
+ trailing = __builtin_ctz(P);
+ pop = __builtin_popcount(P);
+
+// CHECK: @test_i32
+// CHECK: call i32 @llvm.ctlz.i32
+// CHECK: call i32 @llvm.cttz.i32
+// CHECK: call i32 @llvm.ctpop.i32
+}
+
+void test_i64(float P) {
+ leading = __builtin_clzll(P);
+ trailing = __builtin_ctzll(P);
+ pop = __builtin_popcountll(P);
+// CHECK: @test_i64
+// CHECK: call i64 @llvm.ctlz.i64
+// CHECK: call i64 @llvm.cttz.i64
+// CHECK: call i64 @llvm.ctpop.i64
+}