Debian Codegraph @

clang/test/CIR/CodeGenBuiltins/X86/bmi-builtins.c

raw
1 // RUN: %clang_cc1 -x c -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-cir -o %t.cir %s
2 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3 // RUN: %clang_cc1 -x c++ -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-cir -o %t.cir %s
4 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
5
6 // RUN: %clang_cc1 -x c -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s
7 // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
8 // RUN: %clang_cc1 -x c++ -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s
9 // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
10
11 // RUN: %clang_cc1 -x c -ffreestanding -triple=x86_64-unknown-linux -emit-llvm -Wall -Werror %s -o - | FileCheck %s -check-prefix=OGCG
12 // RUN: %clang_cc1 -x c++ -ffreestanding -triple=x86_64-unknown-linux -emit-llvm -Wall -Werror %s -o - | FileCheck %s -check-prefix=OGCG
13
14 // This test mimics clang/test/CodeGen/X86/bmi-builtins.c, which eventually
15 // CIR shall be able to support fully.
16
17 #include <immintrin.h>
18
19 unsigned short test__tzcnt_u16(unsigned short __X) {
20 // CIR-LABEL: __tzcnt_u16
21 // CIR: {{%.*}} = cir.call_llvm_intrinsic "cttz" {{%.*}} : (!u16i, !cir.bool) -> !u16i
22 // LLVM-LABEL: __tzcnt_u16
23 // LLVM: i16 @llvm.cttz.i16(i16 %{{.*}}, i1 false)
24 // OGCG-LABEL: __tzcnt_u16
25 // OGCG: i16 @llvm.cttz.i16(i16 %{{.*}}, i1 false)
26 return __tzcnt_u16(__X);
27 }
28
29 unsigned int test__tzcnt_u32(unsigned int __X) {
30 // CIR-LABEL: __tzcnt_u32
31 // CIR: {{%.*}} = cir.call_llvm_intrinsic "cttz" {{%.*}} : (!u32i, !cir.bool) -> !u32i
32 // LLVM-LABEL: __tzcnt_u32
33 // LLVM: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false)
34 // OGCG-LABEL: __tzcnt_u32
35 // OGCG: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false)
36 return __tzcnt_u32(__X);
37 }
38
39 #ifdef __x86_64__
40 unsigned long long test__tzcnt_u64(unsigned long long __X) {
41 // CIR-LABEL: __tzcnt_u64
42 // CIR: {{%.*}} = cir.call_llvm_intrinsic "cttz" {{%.*}} : (!u64i, !cir.bool) -> !u64i
43 // LLVM-LABEL: __tzcnt_u64
44 // LLVM: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
45 // OGCG-LABEL: __tzcnt_u64
46 // OGCG: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
47 return __tzcnt_u64(__X);
48 }
49 #endif