summaryrefslogtreecommitdiff
path: root/test/CodeGen/bitscan-builtins.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGen/bitscan-builtins.c')
-rw-r--r--test/CodeGen/bitscan-builtins.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/CodeGen/bitscan-builtins.c b/test/CodeGen/bitscan-builtins.c
new file mode 100644
index 000000000000..ae817e815749
--- /dev/null
+++ b/test/CodeGen/bitscan-builtins.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+#include <immintrin.h>
+
+int test_bit_scan_forward(int a) {
+ return _bit_scan_forward(a);
+// CHECK: @test_bit_scan_forward
+// CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(
+// CHECK: ret i32 %[[call]]
+}
+
+int test_bit_scan_reverse(int a) {
+ return _bit_scan_reverse(a);
+// CHECK: %[[call:.*]] = call i32 @llvm.ctlz.i32(
+// CHECK: %[[sub:.*]] = sub nsw i32 31, %[[call]]
+// CHECK: ret i32 %[[sub]]
+}