Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / PowerPC / builtins-ppc-xlcompat-popcnt.c
blobf2934a17db2d853d3fafd704a6f2fa1e6f78c77c
1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu \
3 // RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
4 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu \
5 // RUN: -emit-llvm %s -o - -target-cpu pwr8 | FileCheck %s
6 // RUN: %clang_cc1 -triple powerpc-unknown-aix \
7 // RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
8 // RUN: %clang_cc1 -triple powerpc64-unknown-aix \
9 // RUN: -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
11 extern unsigned int ui;
12 extern unsigned long long ull;
14 // CHECK-LABEL: @test_builtin_ppc_poppar4(
15 // CHECK: [[TMP2:%.*]] = call i32 @llvm.ctpop.i32(i32 {{.*}})
16 // CHECK-NEXT: [[TMP3:%.*]] = and i32 [[TMP2]], 1
17 // CHECK-NEXT: ret i32 [[TMP3]]
19 int test_builtin_ppc_poppar4() {
20 return __builtin_ppc_poppar4(ui);
23 // CHECK-LABEL: @test_builtin_ppc_poppar8(
24 // CHECK: [[TMP2:%.*]] = call i64 @llvm.ctpop.i64(i64 {{.*}})
25 // CHECK-NEXT: [[TMP3:%.*]] = and i64 [[TMP2]], 1
26 // CHECK-NEXT: [[CAST:%.*]] = trunc i64 [[TMP3]] to i32
27 // CHECK-NEXT: ret i32 [[CAST]]
29 int test_builtin_ppc_poppar8() {
30 return __builtin_ppc_poppar8(ull);
33 // CHECK-LABEL: @testcntlz4(
34 // CHECK: [[TMP:%.*]] = call i32 @llvm.ctlz.i32(i32 {{%.*}}, i1 false)
35 // CHECK-NEXT: ret i32 [[TMP]]
37 unsigned int testcntlz4(unsigned int value) {
38 return __cntlz4(value);
41 // CHECK-LABEL: @testcntlz8(
42 // CHECK: [[TMP:%.*]] = call i64 @llvm.ctlz.i64(i64 {{%.*}}, i1 false)
43 // CHECK-NEXT: [[CAST:%.*]] = trunc i64 [[TMP]] to i32
44 // CHECK-NEXT: ret i32 [[CAST]]
46 unsigned int testcntlz8(unsigned long long value) {
47 return __cntlz8(value);
50 // CHECK-LABEL: @testcnttz4(
51 // CHECK: [[TMP:%.*]] = call i32 @llvm.cttz.i32(i32 {{%.*}}, i1 false)
52 // CHECK-NEXT: ret i32 [[TMP]]
54 unsigned int testcnttz4(unsigned int value) {
55 return __cnttz4(value);
58 // CHECK-LABEL: @testcnttz8(
59 // CHECK: [[TMP:%.*]] = call i64 @llvm.cttz.i64(i64 {{%.*}}, i1 false)
60 // CHECK-NEXT: [[CAST:%.*]] = trunc i64 [[TMP]] to i32
61 // CHECK-NEXT: ret i32 [[CAST]]
63 unsigned int testcnttz8(unsigned long long value) {
64 return __cnttz8(value);
67 // CHECK-LABEL: @testpopcnt4(
68 // CHECK: [[TMP:%.*]] = call i32 @llvm.ctpop.i32(i32 {{%.*}})
69 // CHECK-NEXT: ret i32 [[TMP]]
71 int testpopcnt4(unsigned int value) {
72 return __popcnt4(value);
75 // CHECK-LABEL: @testpopcnt8(
76 // CHECK: [[TMP:%.*]] = call i64 @llvm.ctpop.i64(i64 {{%.*}})
77 // CHECK-NEXT: [[CAST:%.*]] = trunc i64 [[TMP]] to i32
78 // CHECK-NEXT: ret i32 [[CAST]]
80 int testpopcnt8(unsigned long long value) {
81 return __popcnt8(value);