|
| 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/lzcnt-builtins.c, which eventually |
| 15 | +// CIR shall be able to support fully. |
| 16 | + |
| 17 | +#include <immintrin.h> |
| 18 | + |
| 19 | +unsigned int test__lzcnt16(unsigned short __X) { |
| 20 | + // CIR-LABEL: __lzcnt16 |
| 21 | + // CIR: {{%.*}} = cir.call_llvm_intrinsic "ctlz" {{%.*}} : (!u16i, !cir.bool) -> !u16i |
| 22 | + // LLVM-LABEL: __lzcnt16 |
| 23 | + // LLVM: @llvm.ctlz.i16(i16 %{{.*}}, i1 false) |
| 24 | + // OGCG-LABEL: __lzcnt16 |
| 25 | + // OGCG: @llvm.ctlz.i16(i16 %{{.*}}, i1 false) |
| 26 | + return __lzcnt16(__X); |
| 27 | +} |
| 28 | + |
| 29 | +unsigned int test__lzcnt32(unsigned int __X) { |
| 30 | + // CIR-LABEL: __lzcnt32 |
| 31 | + // CIR: {{%.*}} = cir.call_llvm_intrinsic "ctlz" {{%.*}} : (!u32i, !cir.bool) -> !u32i |
| 32 | + // LLVM-LABEL: __lzcnt32 |
| 33 | + // LLVM: @llvm.ctlz.i32(i32 %{{.*}}, i1 false) |
| 34 | + // OGCG-LABEL: __lzcnt32 |
| 35 | + // OGCG: @llvm.ctlz.i32(i32 %{{.*}}, i1 false) |
| 36 | + return __lzcnt32(__X); |
| 37 | +} |
| 38 | + |
| 39 | +unsigned long long test__lzcnt64(unsigned long long __X) { |
| 40 | + // CIR-LABEL: __lzcnt64 |
| 41 | + // CIR: {{%.*}} = cir.call_llvm_intrinsic "ctlz" {{%.*}} : (!u64i, !cir.bool) -> !u64i |
| 42 | + // LLVM-LABEL: __lzcnt64 |
| 43 | + // LLVM: @llvm.ctlz.i64(i64 %{{.*}}, i1 false) |
| 44 | + // OGCG-LABEL: __lzcnt64 |
| 45 | + // OGCG: @llvm.ctlz.i64(i64 %{{.*}}, i1 false) |
| 46 | + return __lzcnt64(__X); |
| 47 | +} |
| 48 | + |
| 49 | +unsigned int test__lzcnt_u32(unsigned int __X) { |
| 50 | + // CIR-LABEL: _lzcnt_u32 |
| 51 | + // CIR: {{%.*}} = cir.call_llvm_intrinsic "ctlz" {{%.*}} : (!u32i, !cir.bool) -> !u32i |
| 52 | + // LLVM-LABEL: _lzcnt_u32 |
| 53 | + // LLVM: @llvm.ctlz.i32(i32 %{{.*}}, i1 false) |
| 54 | + // OGCG-LABEL: _lzcnt_u32 |
| 55 | + // OGCG: @llvm.ctlz.i32(i32 %{{.*}}, i1 false) |
| 56 | + return _lzcnt_u32(__X); |
| 57 | +} |
| 58 | + |
| 59 | +unsigned long long test__lzcnt_u64(unsigned long long __X) { |
| 60 | + // CIR-LABEL: _lzcnt_u64 |
| 61 | + // CIR: {{%.*}} = cir.call_llvm_intrinsic "ctlz" {{%.*}} : (!u64i, !cir.bool) -> !u64i |
| 62 | + // LLVM-LABEL: _lzcnt_u64 |
| 63 | + // LLVM: @llvm.ctlz.i64(i64 %{{.*}}, i1 false) |
| 64 | + // OGCG-LABEL: _lzcnt_u64 |
| 65 | + // OGCG: @llvm.ctlz.i64(i64 %{{.*}}, i1 false) |
| 66 | + return _lzcnt_u64(__X); |
| 67 | +} |
0 commit comments